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

Provide focus fallback behaviour for firstContentElement on Modal #54684

Open
getdave opened this issue Sep 21, 2023 · 0 comments
Open

Provide focus fallback behaviour for firstContentElement on Modal #54684

getdave opened this issue Sep 21, 2023 · 0 comments
Labels
[Feature] Component System WordPress component system [Package] Components /packages/components [Type] Enhancement A suggestion for improvement.

Comments

@getdave
Copy link
Contributor

getdave commented Sep 21, 2023

#54590 saw a new value firstContentElement for the focusOnMount prop of Modal. This focuses the first element within the Modal's contents as oppposed to anywhere within the Modal.

Folks suggested that if the focus algorithm finds no focusable elements in the content, it ought to fallback to finding any focusable element within the entire Modal.

There was some disagreement as to how that would be done.


It's going to be pretty challenging with the current implementation though as it relies on moving the focus ref between elements.

Another option could be to console.warn() if no focusable is found?

A console.warn() is probably better than nothing, but I'd personally like to find a way to fallback more gracefully. We can always rework the implementation if necessary, especially now that we have a separate value for this behaviour.

Originally posted by @ciampo in #54590 (comment)

@getdave getdave added [Package] Components /packages/components [Feature] Component System WordPress component system [Type] Enhancement A suggestion for improvement. labels Sep 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Component System WordPress component system [Package] Components /packages/components [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

1 participant