Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

bhavanesh2001
Copy link
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
Member

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

@bhavanesh2001
Copy link
Contributor Author

@jfversluis I added a test.

@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

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
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
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?

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Entry Completed Event Triggered Twice
3 participants