Open jonmdev opened 1 year ago
Duplicate of #16357
We can't have unfocusing an entry be a side effect of closing the SoftKeyboard for various a11y reasons, but we do need to supply an API that will let users fill in what they were using the unfocused event for. Which is what the issue linked above should do.
Editor starts up with flashing cursor (focused)
Something has to have focus. The only way to give nothing focus is to give something wrong focus. In XF we would focus the page but this horribly broke accessibility. It doesn't really make sense from an a11y perspective to completely unfocus anything on the screen. iOS does a "better job" of implementing this concept because it can resign most first responders but it will still remember where you left off last when you engage VO or keyboard commands.
Hi @jonmdev. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
Most of the developers doesn't care if entry unfocused on closing keyboard or not. They just need events when an entry keyboard is opening and closing that's all for that specific entry only.
since unfocus event is not possible now. Is there any way I can know when keyboard is closing and opening for a specific entry that would be enough for me to serve as unfocus event.
I am migrating a very big application which depends heavily on entry unfocus event I can't implement user stopped typing behavior at every place it would not get approved
for now android is priority I am fine with writing native code.
If anyone achieved it kindly let me know how
Thanks
Verified this issue with Visual Studio 17.10.0 Preview 4 (8.0.0-rc.2.9530 & 8.0.21).I can repro this issue with sample project.
Description
Two problems are seen regarding Focus of Editor objects:
1) Android functions necessary to capture the user's close button click of the on screen keyboard are missing from Maui. 2) Editors start up in Android/Windows/iOS already focused (or appearing focused) with a blinking cursor in them.
This is demonstrated by the bug project below with the following code in
MauiProgram.cs
:And the following code in
App.xaml.cs
:The main Android problem is described by these links:
https://stackoverflow.com/questions/3940127/intercept-back-button-from-soft-keyboard https://stackoverflow.com/questions/3988478/block-back-button-in-android/3988567
To summarize,
android.OnBackPressed
is not called when the back button is clicked if the keyboard is open. We need some combination of:onKeyDown
,onKeyUp
,dispatchKeyEvent
, and/ordispatchKeyEventPreIme
to capture the close command to the soft keyboard in Android.None of these are accessible via the API: https://github.com/dotnet/docs-maui/blob/main/docs/fundamentals/app-lifecycle.md
Since we cannot inherit from Android Application to override these events in the Maui program build process, we then have no way to access these events.
Any fix would be appreciated. Adding the missing functions/events to the Lifecycle API in Android would fix it.
It is also noted as a secondary issue that when you play the project in Android or Windows and I believe iOS, it will start up with the Editor focused with a blinking cursor even though there is no code requesting it to be focused anywhere. The project should start up with no blinking cursor and no Editor focused.
Steps to Reproduce
android.OnBackPressed
, as is known to be the case.onBackPressed
only runs when the keyboard is already closed).https://stackoverflow.com/questions/3940127/intercept-back-button-from-soft-keyboard https://stackoverflow.com/questions/3988478/block-back-button-in-android/3988567
Link to public reproduction project repository
https://github.com/jonmdev/Android-Editor-Close-Bug
Version with bug
8.0.96
Is this a regression from previous behavior?
No, this is something new
Affected platforms
iOS, Android, Windows
Did you find any workaround?
Correct behavior needs the missing functions added here:
https://github.com/dotnet/docs-maui/blob/main/docs/fundamentals/app-lifecycle.md