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

Ensure focus of input when InputControl spinner arrows are pressed #25753

Merged
merged 1 commit into from
Oct 2, 2020

Conversation

stokesman
Copy link
Contributor

@stokesman stokesman commented Sep 30, 2020

There's currently no separate issue for this. It was reported here: #25528 (comment)

In Firefox (and maybe some other UA out there) number inputs are not focused when their spinners are pressed:
focus-spinner

As demonstrated in the screen capture it prevents the value from updating. Without focus the spinners cannot cause the component to update due to value sync logic introduced in 2d5106a.

This PR adds a little workaround to fix the issue by adding a handler for onmousedown when InputControl is of number type. The handler focuses the input in case it's not.

How has this been tested?

With WordPress 5.5.1

Types of changes

bug fix

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • [n/a] My code follows the accessibility standards.
  • My code has proper inline documentation.
  • [n/a] I've included developer documentation if appropriate.
  • [n/a] I've updated all React Native files affected by any refactorings/renamings in this PR.

This is redundant for most browsers. Though Firefox, for example,
does not focus the input when the spinners are clicked. Without
focus the spinners cannot cause the component to update due to
value sync logic introduced in 2d5106a
@stokesman stokesman marked this pull request as ready for review September 30, 2020 22:00
@Sven74Muc
Copy link

Just saw this same effect in the sidebar of "Gutenberg Blocks – Ultimate Addons for Gutenberg" #25753

Looks like it's a general Gutenberg issue

@stokesman stokesman changed the title Ensures focus of input when InputControl spinner arrows are pressed Ensure focus of input when InputControl spinner arrows are pressed Oct 2, 2020
@stokesman
Copy link
Contributor Author

@Sven74Muc, thanks again for the initial report and yes, the issue could be present in quite a few places. Fortunately, they'll all be resolved by a fix in one place.

@ItsJonQ, I thought you'd like to be aware of the issue this PR is aims to fix since it was introduced by the recent sync changes in InputControl.

@ItsJonQ ItsJonQ self-requested a review October 2, 2020 20:58
Copy link

@ItsJonQ ItsJonQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 from me! Thanks @stokesman . Tested locally on Safari and Firefox, and it looks like it's working 🙌

@ItsJonQ ItsJonQ merged commit 4e7c772 into WordPress:master Oct 2, 2020
@github-actions github-actions bot added this to the Gutenberg 9.2 milestone Oct 2, 2020
ItsJonQ pushed a commit that referenced this pull request Oct 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants