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

useFocusOnMount: add ability to handle focus at every render #52326

Open
afercia opened this issue Jul 5, 2023 · 0 comments
Open

useFocusOnMount: add ability to handle focus at every render #52326

afercia opened this issue Jul 5, 2023 · 0 comments
Labels
[Feature] NUX Anything that impacts the new user experience [Package] Compose /packages/compose [Type] Enhancement A suggestion for improvement.

Comments

@afercia
Copy link
Contributor

afercia commented Jul 5, 2023

Description

There are legitimate cases where a component needs to handle initial focus at every render.

For example, some of the 'Welcome guide' modal dialogs do have 'steps' to show new content within the modal dialog. When a new step is rendered, the modal dialog needs to set focus again at the top of the fcontent: preferably set focus to the modal dialog container itself.

#52300 implemented such behavior via an ad-hoc implementation in the Guide component. I'm thinking this behavior should be handled by useFocusOnMount instead, to avoid ad-hoc implementations and avoid almost-duplicate functionality and code.

Any thoughts welcome.

Step-by-step reproduction instructions

  • Go to the Post editor > Options > Welcome guide
  • Observe initial focus is set to the modal dialog container: Press Tab and observe focus foes to the Close button.
  • Click 'Next' to go to the next step.
  • Observe initial focus is set to the modal dialog container: Press Tab and observe focus foes to the Close button.
  • Same when clicking 'Previous'.
  • Observe thie focus behavior is currently handled via an ad-hoc implementation in the Guide component.
  • Observe that useFocusOnMount runs regardless because it uses the default value true.

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@afercia afercia added [Type] Enhancement A suggestion for improvement. [Feature] NUX Anything that impacts the new user experience [Package] Compose /packages/compose labels Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] NUX Anything that impacts the new user experience [Package] Compose /packages/compose [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

1 participant