-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Focus on name field when mounting and update summary field UI #39050
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
Conversation
Test Results SummaryCommit SHA: 5a724fc
To view the full API test report, click here. To view the full E2E test report, click here. To view all test reports, visit the WooCommerce Test Reports Dashboard. |
louwie17
left a comment
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.
This tested well, but pushing it back as I don't think we should make it the default for the name block (as mentioned in the comment below), but instead make it a configuration option through attributes.
|
|
||
| useEffect( () => { | ||
| if ( inputRef.current ) { | ||
| inputRef.current.focus(); |
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.
I don't think this should be the default for the name block, as it could very well be used in other contexts where the auto focus wouldn't make sense.
I think we are better off adding this as an option through attributes. We may want a autoFocus attribute. You can see the radio block for examples on using additional attributes, and how to get the value within the component.
I would also suggest using the autoFocus prop for the inputControl instead of going the above route.
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.
Thanks for the suggestion. I didn't knew that there was an autoFocus prop since we don't have the type definitions :(
|
Hi @louwie17, Apart from reviewing the code changes, please make sure to review the testing instructions as well. You can follow this guide to find out what good testing instructions should look like: |
|
@louwie17 I had to add a eslint ignore, apparently we have a rule to disallow using autoFocus. Is that fine, since that's the behavior we want in this case? |
259c141 to
54c2726
Compare
louwie17
left a comment
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.
Thanks for addressing the changes @nathanss, this still tested well! Nice work!
I had to add a eslint ignore, apparently we have a rule to disallow using autoFocus. Is that fine, since that's the behavior we want in this case?
I think this is fine given it's an option and we can easily disable it again by the user of the attribute if we want to.
I will cc: @jarekmorawski on this though, just incase there are similar rules for design within WooCommerce?
But I am good if we merge this as is.
Submission Review Guidelines:
Changes proposed in this Pull Request:
Focus on name field when mounting and update summary field UI
Closes #38204 .
How to test the changes in this Pull Request:
Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:
Changelog entry
Significance
Type
Message
Comment
Focus on name field when mounting and update summary field UI