Skip to content

[Android] Fix: Prevent duplicate Completed event when setting ReturnType in Entry#28018

Merged
PureWeen merged 3 commits intodotnet:mainfrom
bhavanesh2001:fix_27992
Mar 18, 2025
Merged

[Android] Fix: Prevent duplicate Completed event when setting ReturnType in Entry#28018
PureWeen merged 3 commits intodotnet:mainfrom
bhavanesh2001:fix_27992

Conversation

@bhavanesh2001
Copy link
Copy Markdown
Contributor

@bhavanesh2001 bhavanesh2001 commented Feb 24, 2025

Description of Change

This change fixes an issue where the Completed event in Entry triggers twice on Android when setting ReturnType.

Root Cause

  • When setting ReturnType, Android internally updates the ImeOptions, which can cause multiple events to be fired.
  • Both ImeActions (ImeAction.Done, ImeAction.Search, etc.) and physical keyboard Enter presses were not consistently handled.
  • The Completed event is invoked once by the soft keyboard action (ImeAction) and again by the physical Enter key press (KeyEventActions.Up).
  • This results in duplicate event triggers when pressing the return key.

Fix Implementation

  • Prevent KeyEventActions.Up from firing unnecessarily if the event was already handled by the soft keyboard.

Issues Fixed

Fixes #27992

@bhavanesh2001 bhavanesh2001 requested a review from a team as a code owner February 24, 2025 20:10
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Feb 24, 2025
@bhavanesh2001 bhavanesh2001 changed the title [Android] Fix: Prevent duplicate Completed event when manually mapping ReturnType in Entry [Android] Fix: Prevent duplicate Completed event when setting ReturnType in Entry Feb 24, 2025
@jfversluis
Copy link
Copy Markdown
Member

Awesome stuff @bhavanesh2001! Can we add a test for this?

@bhavanesh2001
Copy link
Copy Markdown
Contributor Author

@jfversluis I added a test.

@jsuarezruiz
Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

jfversluis
jfversluis previously approved these changes Feb 25, 2025
@jfversluis jfversluis added this to the .NET 9 SR5 milestone Feb 25, 2025
@bhavanesh2001
Copy link
Copy Markdown
Contributor Author

Screenshot 2025-02-26 at 7 55 59 AM

TappingNextMovesToNextElement is failing due to the change.

I'm a bit confused about TappingDoneClosesKeyboard. I thought the default behavior shouldn't close the keyboard, but should it?

@bhavanesh2001
Copy link
Copy Markdown
Contributor Author

bhavanesh2001 commented Feb 26, 2025

It seems like the keyboard should close when ReturnType is set to Done, as mentioned in this PR.

In the case of Search, Go, or Send, the EditorAction will be invoked for KeyEventActions (even with soft keyboard). To prevent the Completed event from being triggered twice, we can set Handled to true for these cases only. This will not interfere with cases where ReturnType is set to Next or Done.

I will include a commit for this change.

@PureWeen thoughts?

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@bhavanesh2001
Copy link
Copy Markdown
Contributor Author

Screenshot 2025-02-27 144203
Screenshot 2025-02-27 144258
Screenshot 2025-02-27 144134

@bhavanesh2001
Copy link
Copy Markdown
Contributor Author

/rebase

@jsuarezruiz
Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen PureWeen modified the milestones: .NET 9 SR5, .NET 9 SR6 Mar 7, 2025
@PureWeen PureWeen merged commit c451130 into dotnet:main Mar 18, 2025
123 checks passed
@bhavanesh2001 bhavanesh2001 deleted the fix_27992 branch March 19, 2025 01:51
@github-actions github-actions bot locked and limited conversation to collaborators Apr 18, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Entry Completed Event Triggered Twice

4 participants