-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[Mobile] - Android - Bring the Keyboard back when closing modals #57069
[Mobile] - Android - Bring the Keyboard back when closing modals #57069
Conversation
Size Change: 0 B Total Size: 1.71 MB ℹ️ View Unchanged
|
Flaky tests detected in ef48c7f. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7213191517
|
acf6641
to
b2d6ead
Compare
… show the keyboard if there's a focused TextInput
…osing the Modal so it shows the Keyboard on Android for focused TextInputs
… hide the keyboard without triggering blur events
…, as their names are self-explanatory.
5bd2dcc
to
ef48c7f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🎊 !
I added a couple of comments but none shouldn't block the merge of the PR.
...java/org/wordpress/mobile/ReactNativeGutenbergBridge/RNReactNativeGutenbergBridgeModule.java
Outdated
Show resolved
Hide resolved
…ocus changed, when we show the Modals these are shown on top of the editor activity. It also adds an option to delay this for full screen modals
…ForBackdrop props to improve performance on Android
Thank you for the review and for testing these changes! I introduced a few changes related to the keyboard logic and I also added two props for the Modal component that I think it'd improve the Android performance a bit. Let me know if you have any questions about it. Thanks! |
...java/org/wordpress/mobile/ReactNativeGutenbergBridge/RNReactNativeGutenbergBridgeModule.java
Outdated
Show resolved
Hide resolved
...java/org/wordpress/mobile/ReactNativeGutenbergBridge/RNReactNativeGutenbergBridgeModule.java
Outdated
Show resolved
Hide resolved
...java/org/wordpress/mobile/ReactNativeGutenbergBridge/RNReactNativeGutenbergBridgeModule.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🎊 ! I've tested the latest changes and worked as expected, thanks @geriux for addressing my suggestions 🙇 !
I added some minor comments but we could skip them to merge the PR. Alternatively, since the PR will be merged into a feature branch, we could address some of them directly there.
I introduced a few changes related to the keyboard logic and I also added two props for the Modal component that I think it'd improve the Android performance a bit. Let me know if you have any questions about it. Thanks!
That's great, do you foresee we should check modals in other scenarios aside the keyboard issue due to this change?
I've tested in an actual device with a local build and can't really tell if the performance improved when showing/hiding modals. In any case, I presume that this will be more visible when testing installable builds.
...java/org/wordpress/mobile/ReactNativeGutenbergBridge/RNReactNativeGutenbergBridgeModule.java
Outdated
Show resolved
Hide resolved
…also removes the delay functionality as it is no longer needed. It fixes an issue where mKeyboardRunnable was not being set. It removes the delay logic from the Bottom Sheet component and the bridge.
...java/org/wordpress/mobile/ReactNativeGutenbergBridge/RNReactNativeGutenbergBridgeModule.java
Outdated
Show resolved
Hide resolved
…nable instead of getting it as an param
...java/org/wordpress/mobile/ReactNativeGutenbergBridge/RNReactNativeGutenbergBridgeModule.java
Outdated
Show resolved
Hide resolved
@fluiddot Thank you for the review and feedback! I'll merge this PR once the checks pass 🚀 |
71b3409
into
rnmobile/fix/avoid-keyboard-dismiss-when-interacting-text-blocks
* Use debounce in Aztec's blur function * Execute `focus` UI block before other blocks * Add `hideAndroidSoftKeyboard` to RN bridge * Add `blurOnUnmount` to Aztec input state manager. This function will help us to deal with the special case of unfocusing an Aztec view upon unmounting. * Dismiss keyboard when Aztec view unmounts This was previously handled in the `RichText` component. * Fix unit test related to `AztecInputState` after adding debounce to `blur` function * Remove console warning from `hideAndroidSoftKeyboard` * Update inline comments of `blurOnUnmount` function * [Mobile] - Android - Bring the Keyboard back when closing modals (#57069) * React Native Bridge - Android - Introduces showAndroidSoftKeyboard to show the keyboard if there's a focused TextInput * Mobile - Bottom Sheet - Adds usage of showAndroidSoftKeyboard when closing the Modal so it shows the Keyboard on Android for focused TextInputs * React Native Bridge - Android - Introduces hideAndroidSoftKeyboard to hide the keyboard without triggering blur events * React Native Bridge - Remove console warnings for unsupported methods, as their names are self-explanatory. * Update showAndroidSoftKeyboard to take into account when the window focus changed, when we show the Modals these are shown on top of the editor activity. It also adds an option to delay this for full screen modals * Mobile - BottomSheet - Enable hardwareAccelerated and useNativeDriverForBackdrop props to improve performance on Android * Update snapshots * Removes hasWindowFocus condition as it is not being called hence not needed * Refactor showAndroidSoftKeyboard to split into several functions, it also removes the delay functionality as it is no longer needed. It fixes an issue where mKeyboardRunnable was not being set. It removes the delay logic from the Bottom Sheet component and the bridge. * Updates createShowKeyboardRunnable to get the activity within the runnable instead of getting it as an param * Remove unneeded check * Update `react-native-editor` changelog --------- Co-authored-by: Gerardo Pacheco <gerardo.pacheco@automattic.com>
* Use debounce in Aztec's blur function * Execute `focus` UI block before other blocks * Add `hideAndroidSoftKeyboard` to RN bridge * Add `blurOnUnmount` to Aztec input state manager. This function will help us to deal with the special case of unfocusing an Aztec view upon unmounting. * Dismiss keyboard when Aztec view unmounts This was previously handled in the `RichText` component. * Fix unit test related to `AztecInputState` after adding debounce to `blur` function * Remove console warning from `hideAndroidSoftKeyboard` * Update inline comments of `blurOnUnmount` function * [Mobile] - Android - Bring the Keyboard back when closing modals (#57069) * React Native Bridge - Android - Introduces showAndroidSoftKeyboard to show the keyboard if there's a focused TextInput * Mobile - Bottom Sheet - Adds usage of showAndroidSoftKeyboard when closing the Modal so it shows the Keyboard on Android for focused TextInputs * React Native Bridge - Android - Introduces hideAndroidSoftKeyboard to hide the keyboard without triggering blur events * React Native Bridge - Remove console warnings for unsupported methods, as their names are self-explanatory. * Update showAndroidSoftKeyboard to take into account when the window focus changed, when we show the Modals these are shown on top of the editor activity. It also adds an option to delay this for full screen modals * Mobile - BottomSheet - Enable hardwareAccelerated and useNativeDriverForBackdrop props to improve performance on Android * Update snapshots * Removes hasWindowFocus condition as it is not being called hence not needed * Refactor showAndroidSoftKeyboard to split into several functions, it also removes the delay functionality as it is no longer needed. It fixes an issue where mKeyboardRunnable was not being set. It removes the delay logic from the Bottom Sheet component and the bridge. * Updates createShowKeyboardRunnable to get the activity within the runnable instead of getting it as an param * Remove unneeded check * Update `react-native-editor` changelog --------- Co-authored-by: Gerardo Pacheco <gerardo.pacheco@automattic.com>
This PR is part of #57070
What?
It adds new implementations in the bridge for Android, so we can control hiding and showing the keyboard in some cases.
Why?
To improve the writing flow experience, we'll handle the keyboard manually in some cases.
How?
It adds two methods
showAndroidSoftKeyboard
andhideAndroidSoftKeyboard
in the React Native Bridge package, this functionality will be shared for both the demo app and the host apps as the functionality is kept entirely inRNReactNativeGutenbergBridgeModule
.The
showAndroidSoftKeyboard
method is introduced in theBottomSheet
component, to prevent not displaying the Keyboard when these modals are dismissed and a TextInput was focused prior to opening the Modal.This is only needed in Android since iOS handles this internally.
It's used in three parts of the code:
componentWillUnmount
some Modals get removed completely when they're hidden, which prevents other callbacks to be triggered likeonModalHide
.onHardwareButtonPress
when a user dismisses the modal by using the hardware back button on Android.onCloseBottomSheet
triggered when the modal is hidden either by swiping down, or tapping on the Modal backdrop.Testing Instructions
Case 1 - Opening the block settings of a Paragraph block
Case 2 - Changing the text color of a Paragraph block
Case 3 - Changing the text alignment
Case 4 - Opening the block inserter when focused on a Paragraph block
Testing Instructions for Keyboard
N/A
Screenshots or screencast
Case1_Keyboard.mov
Case2_Keyboard.mov
Case3_Keyboard.mov
Case4_Keyboard.mov