-
Notifications
You must be signed in to change notification settings - Fork 798
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
Contact Info Block add manual blur to fix focus issues #19367
Conversation
Caution: This PR has changes that must be merged to WordPress.com |
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped. Jetpack plugin:
|
I updated this branch with latest |
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.
Hello @illusaen The changes here are working well. I see the focus correctly switching off of the address inner block now.
One piece of feedback, it was a little hard to review the change because the block was turned from a class into a function AND had the new blur function added in a single commit. As far as I can tell, this is the only new functionality added to the class:
jetpack/projects/plugins/jetpack/extensions/blocks/contact-info/address/edit.native.js
Lines 75 to 81 in 0cb266c
useEffect( () => { if ( isSelected ) { return; } textInputRefs.forEach( ref => ref?.current?.blur() ); }, [ isSelected, textInputRefs ] ); jetpack/projects/plugins/jetpack/extensions/blocks/contact-info/address/edit.native.js
Lines 122 to 130 in 0cb266c
const onBlurTextInput = index => () => { if ( index >= textInputsSelected.length ) { return; } const newTextInputsSelected = [ ...textInputsSelected ]; newTextInputsSelected[ index ] = false; setTextInputsSelected( newTextInputsSelected ); }; jetpack/projects/plugins/jetpack/extensions/blocks/contact-info/address/edit.native.js
Line 144 in 0cb266c
onBlur={ onBlurTextInput( index ) }
As you can see there is no easy way to see that this is the only new functionality, because that code was introduced in the same commit as the conversion to function here: 1168eaa
In the future, splitting out these two updates into two different commits would be helpful.
In this case the change looks pretty safe, and all is working as expected. Nice job with the fix!
@cameronvoell Thanks for your time! I'll definitely do that next time, didn't even think of that! |
Great news! One last step: head over to your WordPress.com diff, D59584-code, and commit it. Thank you! |
r225432-wpcom |
Fixes bug where selecting and typing in an inner block on Contact Info and then exiting out of the block fast (clicking on a different unnested block) would cause cursor to stay in the original inner block and thus result in an unhideable keyboard.
Fixes #3122
Gutenberg-Mobile: #3340
NOTE: Codeclimate mentions that the component (function) is too long/complex; however, since I refactored the class component into a functional one, the entire component itself is a function. I tried refactoring out subcomponents but found that the code was harder to read. I'm going to ignore these suggestions as not relevant to this code.
Changes proposed in this Pull Request:
blur()
call on text input if block is no longer selected.Does this pull request change what data or activity we track or use?
No change to data/tracked activity.
Add changelog entries to affected projects
Added under
changelog/fix-contact-info-focus
.Screenshots
Testing instructions: