useFocusOnMount: add ability to handle focus at every render #52326
Labels
[Feature] NUX
Anything that impacts the new user experience
[Package] Compose
/packages/compose
[Type] Enhancement
A suggestion for improvement.
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 byuseFocusOnMount
instead, to avoid ad-hoc implementations and avoid almost-duplicate functionality and code.Any thoughts welcome.
Step-by-step reproduction instructions
useFocusOnMount
runs regardless because it uses the default valuetrue
.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
The text was updated successfully, but these errors were encountered: