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

Contact Info Block add manual blur to fix focus issues #19367

Merged
merged 8 commits into from
Apr 13, 2021

Conversation

illusaen
Copy link
Contributor

@illusaen illusaen commented Mar 31, 2021

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:

  • Adds manual 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

Before After

Testing instructions:

  • Have Jetpack-enabled site with version > 8.5.
  • Create new post
  • Add contact info block
  • Type 'test' into "Address Line 2"
  • Quickly click on "Email"
  • See that cursor is removed from "Address Line 2" and keyboard hides.

@matticbot
Copy link
Contributor

Caution: This PR has changes that must be merged to WordPress.com
Hello illusaen! These changes need to be synced to WordPress.com - If you 're an a11n, please commandeer and confirm D59584-code works as expected before merging this PR. Once this PR is merged, please commit the changes to WP.com. Thank you!
This revision will be updated with each commit to this PR

@github-actions github-actions bot added [Block] Contact Info [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ labels Mar 31, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Mar 31, 2021

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ All commits were linted before commit.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

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.
Then, add the "[Status] Needs Team review" label and ask someone from your team review the code.
Once you’ve done so, switch to the "[Status] Needs Review" label; someone from Jetpack Crew will then review this PR and merge it to be included in the next Jetpack release.


Jetpack plugin:

  • Next scheduled release: May 4, 2021.
  • Scheduled code freeze: April 26, 2021.

@github-actions github-actions bot added the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Mar 31, 2021
@illusaen illusaen requested a review from cameronvoell March 31, 2021 19:22
@illusaen illusaen added [Status] Needs Team Review [Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack and removed [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! labels Mar 31, 2021
@github-actions github-actions bot added the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Mar 31, 2021
@illusaen illusaen removed the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Apr 2, 2021
@github-actions github-actions bot added the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Apr 5, 2021
@illusaen illusaen removed the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Apr 5, 2021
@jeherve
Copy link
Member

jeherve commented Apr 6, 2021

I updated this branch with latest master to fix unrelated test failures.

Copy link
Contributor

@cameronvoell cameronvoell left a 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:

  1. useEffect( () => {
    if ( isSelected ) {
    return;
    }
    textInputRefs.forEach( ref => ref?.current?.blur() );
    }, [ isSelected, textInputRefs ] );
  2. const onBlurTextInput = index => () => {
    if ( index >= textInputsSelected.length ) {
    return;
    }
    const newTextInputsSelected = [ ...textInputsSelected ];
    newTextInputsSelected[ index ] = false;
    setTextInputsSelected( newTextInputsSelected );
    };

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!

@illusaen
Copy link
Contributor Author

illusaen commented Apr 7, 2021

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.

@cameronvoell Thanks for your time! I'll definitely do that next time, didn't even think of that!

@illusaen illusaen added [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. and removed [Status] Needs Team Review labels Apr 7, 2021
@jeherve jeherve added this to the jetpack/9.7 milestone Apr 13, 2021
@jeherve jeherve removed the [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. label Apr 13, 2021
@jeherve jeherve added the [Status] Ready to Merge Go ahead, you can push that green button! label Apr 13, 2021
@jeherve jeherve changed the title Adding manual blur to fix focus issues for Contact Info inner blocks Contact Info Block add manual blur to fix focus issues Apr 13, 2021
@jeherve jeherve enabled auto-merge (squash) April 13, 2021 07:01
@jeherve jeherve merged commit f7714bb into master Apr 13, 2021
@jeherve jeherve deleted the fix-contact-info-focus branch April 13, 2021 07:08
@github-actions github-actions bot removed the [Status] Ready to Merge Go ahead, you can push that green button! label Apr 13, 2021
@github-actions
Copy link
Contributor

Great news! One last step: head over to your WordPress.com diff, D59584-code, and commit it.
Once you've done so, come back to this PR and add a comment with your changeset ID.

Thank you!

@jeherve
Copy link
Member

jeherve commented May 7, 2021

r225432-wpcom

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Contact Info [Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ Touches WP.com Files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nested Inner Block with Block Group Results in Unhideable Keyboard
4 participants