-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
[RNMobile]: Fix search block focus issues #29500
Conversation
Only adds a shell of a block.
This alert will be removed once styling is added in a later PR.
This will keep the code cleaner and easier to follow.
This toolbar action is now visible in the UI so the temporary alert message is no longer needed.
Was causing issues with layout in iOS. Styling will be addressed fully in a different PR.
…-search-block-button-position
…-search-block-button-position
Moved the CSS_UNIT code to a shared Utils file in preparation for using the same code inside the native implementation of the search block.
Also moved the default values from the web version to the shared utils file.
# Conflicts: # packages/block-library/src/search/edit.native.js # packages/block-library/src/search/rich-text.android.scss # packages/block-library/src/search/rich-text.ios.scss # packages/block-library/src/search/style.native.scss
…le/3073-search-block-settings
# Conflicts: # packages/block-library/src/search/edit.native.js
- Set the onFocus() method to ensure if the placeholder text is clicked on when the block is NOT selected then the block will be selected. - Set isSelected in RichText elements to false for initial draw to prevent odd behavior on iOS where the Search block will attempt to steal focus from other text blocks. - Set the placeholder text to focused when the block is first added.
The focus behavior is looking much better @AmandaRiu 🙌 One thing I noticed is that when you unselect the search block while one of the text fields was selected (with the blinking cursor active) - the blinking cursor stays active on that text field even though another block is now selected, and the user can still type in that field even though a new block is selected. I think the expected behavior would be that when you select a new block, the cursor should not remain active in the previously selected text field of the search block. My hunch is that it would be best to address that in this PR, but let me know if you think a separate PR would be better 🙏 |
Thanks for the review @cameronvoell !
I agree it should be handled in this PR. I'll take a look at it today 🙇♀️ |
Fixes an issue where if the label or button text was selected in the search block and then a different block was selected, the cursor would still be active in the search block text field.
@cameronvoell Issue with text not losing focus when block loses focus has been fixed in 452356a. Ready for another review! 👍 |
@AmandaRiu In my tests it looks like it is fixed for focus on the Button text, and the label text, but not the placeholder text. Steps:
|
This isn't really a concern for mobile, but on web there is an option for `button-only` so this change ensures that we don't try to manipulate a reference that would be null.
Fixed! Ready for another round! |
Hey @guarani 👋 I’ve made the changes we discussed. Ready for another review! |
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.
Tested on iOS and Android, code looks good! Great work, @AmandaRiu! 💯
NOTE:
This PR must be merged before this one can be taken out of draftGutenberg Mobile PR: wordpress-mobile/gutenberg-mobile#3210
Description
Fixes an couples issues found in a previous PR review:
How has this been tested?
Tested on both Android emulator and iOS simulator
Screenshots
iOS before - search block stealing focus from text-based blocks
Screen.Recording.2021-03-02.at.10.27.29.PM.mov
iOS After:
Screen.Recording.2021-03-02.at.10.15.04.PM.mov
Android before - selecting placeholder text field when block not selected:
Screen.Recording.2021-03-02.at.10.26.38.PM.mov
Android after - placeholder text is focused when block first added:
Screen.Recording.2021-03-02.at.10.21.38.PM.mov
Types of changes
Search Block
are focused and passing that state via theisSelected
property of those components.Search Block
'sonFocus
prop to it's child components so when the placeholder text was directly clicked the block would become selected.TextInput
component with thePlainText
component.blur()
method to thePlainText
component and then added auseEffect
to be called when theisSelected
property changes to force thePlainText
to blur when theSearch Block
is no longer selected. Similar things are done in other blocks (Image
,MediaText
,Video
) except they implement a staticgetDerivedStateFromProps
method to do the same thing. It works in those blocks because they are React classes. MySearch Block
is a Function Component so I'm usinguseEffect
to accomplish the same thing.Checklist: