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

Process the hardware enter key as "Done" #16386

Merged
merged 4 commits into from
Jan 19, 2024
Merged

Conversation

PureWeen
Copy link
Member

@PureWeen PureWeen commented Jul 26, 2023

Description of Change

Alternative PR from #14972

This makes android fire completed anytime a user hits the enter key. This behavior now matches iOS and Windows when hitting the enter key on a physical keyboard. This behavior is still different than XF because the focus will still move to the next input control. I realize that behavior will somewhat frustrate XF migration, but keyboard users expect the keyboard to navigate forward so for us to break that default behavior for keyboard users isn't ideal. If the developer wants the entry to capture the keyboard then it's on them to subscribe to the platform view and mark the event as handled.

We'll still need the manual tests because from what I can tell we can't write an automated test for WinUI/iOS/Catalyst

The ultimate fix here would probably be to add our own EditorActions or once we actually have keyboard events in MAUI then users could just interpret these events themselves.

Issues Fixed

Fixes #13921
Fixes #18370

@PureWeen PureWeen changed the title Process the enter key as "Done" Process the hardware enter key as "Done" Jul 26, 2023
@samhouts samhouts added this to the .NET 8 GA milestone Jul 26, 2023
@rachelkang
Copy link
Member

What is the platform default behavior? Does Android process the hardware keyboard "Enter" key the same way as the software keyboard "Enter" key on Done?

@Eilon Eilon added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Aug 3, 2023
@jsuarezruiz
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@samhouts samhouts requested a review from a team August 10, 2023 18:37
jsuarezruiz
jsuarezruiz previously approved these changes Aug 17, 2023
@PureWeen PureWeen marked this pull request as draft August 17, 2023 17:40
@rachelkang
Copy link
Member

rachelkang commented Aug 17, 2023

summarizing offline conversation for my own future reference -
Android IME type triggers the return event on SW keyboard, hides the SW keyboard, and keeps or moves keyboard focus.
Android IME type does NOT trigger the return event on HW keyboard. Pressing Enter on HW keyboard always moves keyboard focus to next control.

TODO: Investigate behavior on other platforms to better understand what the expectation is here, before proceeding to a final decision

WINUI:

Customized code that does the following

  • ReturnType: Completed fires completed event and then keeps focus on current control
  • ReturnType: Next fires completed event and then moves focus to next control
image

IOS:

Does the same thing as WinUI because we have custom code that subscribes to "ShouldReturn" and then based on the ReturnType we perform different operations.

@PureWeen PureWeen force-pushed the fix_keyboard_completed branch from f3a9af5 to b83dd72 Compare September 6, 2023 06:08
@PureWeen PureWeen marked this pull request as ready for review September 6, 2023 06:53
Copy link
Member

@rachelkang rachelkang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question below, and I think it would be helpful to add a test here to ensure the Completed event gets fired when we want it to. Otherwise LGTM!

@samhouts samhouts modified the milestones: .NET 8 GA, Under Consideration Sep 19, 2023
@PureWeen PureWeen force-pushed the fix_keyboard_completed branch from 1f8b0db to 4871aa6 Compare September 20, 2023 17:03
@PureWeen PureWeen requested a review from rachelkang September 20, 2023 17:38
rachelkang
rachelkang previously approved these changes Sep 20, 2023
Copy link
Member

@rachelkang rachelkang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Good candidate for a manual test.
Would be good to re-test this scenario after #17463 gets fixed

@PureWeen PureWeen marked this pull request as draft September 20, 2023 20:41
@samhouts samhouts added the stale Indicates a stale issue/pr and will be closed soon label Oct 5, 2023
@samhouts
Copy link
Member

samhouts commented Oct 5, 2023

What are we doing with this one?

@samhouts samhouts added the s/pr-needs-author-input PR needs an update from the author label Oct 5, 2023
@ghost
Copy link

ghost commented Oct 5, 2023

Hi @PureWeen. We have added the "s/pr-needs-author-input" label to this issue, which indicates that we have an open question/action for you before we can take further action. This PRwill be closed automatically in 14 days if we do not hear back from you by then - please feel free to re-open it if you come back to this PR after that time.

@ghost ghost closed this Oct 9, 2023
@PureWeen PureWeen reopened this Nov 22, 2023
@PureWeen
Copy link
Member Author

/rebase

@PureWeen PureWeen marked this pull request as ready for review December 13, 2023 23:47
@github-actions github-actions bot force-pushed the fix_keyboard_completed branch from b648f02 to 58c717d Compare December 13, 2023 23:47
@PureWeen PureWeen marked this pull request as draft December 14, 2023 16:10
@samhouts samhouts added the stale Indicates a stale issue/pr and will be closed soon label Jan 8, 2024
@PureWeen PureWeen requested a review from rachelkang January 10, 2024 18:01
Comment on lines +328 to +334
// On API 34 it looks like they fixed the issue where the actionId is ImeAction.ImeNull when using a keyboard
// so I'm just setting the actionId here to whatever the user has
if (actionId == ImeAction.ImeNull && evt?.KeyCode == Keycode.Enter)
{
actionId = currentInputImeFlag;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So for pre api34 now - if we check the actionId on the entrys, after the action is completed, it should no longer say the actionId is null and instead show the expected one?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still just a bit confused because that's my interpretatin of your comment and also because I'm seeing this code both here, and in EntryHandler.Android.cs

Copy link
Member

@rachelkang rachelkang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! As discussed offline, todos include:

  • Ensuring this is well reflected in the manual tests; if it indeed exists, ensuring it becomes activated for Android
  • Cleaning up the Debug statements in the PR
  • Fixing up the PR description to accurately reflect the fix being made: Entry_Completed gets triggered when pressing the hardware enter key on Android pre-api34 (already happening on api34+ due to android API changes)

once that's all cleaned up, this should be good to go!!!

@PureWeen PureWeen force-pushed the fix_keyboard_completed branch 2 times, most recently from 0fbba96 to 2c187cc Compare January 16, 2024 20:26
@PureWeen PureWeen marked this pull request as ready for review January 16, 2024 23:18
@PureWeen PureWeen requested a review from rachelkang January 16, 2024 23:26
@PureWeen
Copy link
Member Author

/rebase

@github-actions github-actions bot force-pushed the fix_keyboard_completed branch from baeea2c to 81b99f4 Compare January 17, 2024 22:48
@PureWeen
Copy link
Member Author

/rebase

@github-actions github-actions bot force-pushed the fix_keyboard_completed branch from 82b248a to 2ecd219 Compare January 18, 2024 18:11
Copy link
Member

@rachelkang rachelkang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@PureWeen PureWeen merged commit c02195d into main Jan 19, 2024
46 checks passed
@PureWeen PureWeen deleted the fix_keyboard_completed branch January 19, 2024 20:43
@github-actions github-actions bot locked and limited conversation to collaborators Feb 19, 2024
@Eilon Eilon added the area-keyboard Keyboard, soft keyboard label May 13, 2024
@samhouts samhouts removed this from the Under Consideration milestone Jul 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-keyboard Keyboard, soft keyboard fixed-in-8.0.7 fixed-in-9.0.100-preview.1.9973 legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor stale Indicates a stale issue/pr and will be closed soon
Projects
None yet
5 participants