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

autoFocus polyfill deviates from HTML autofocus global attribute spec #23231

Open
kate-hall opened this issue Feb 3, 2022 · 1 comment
Open

Comments

@kate-hall
Copy link

kate-hall commented Feb 3, 2022

Based on this comment: #11851 (comment), it appears autoFocus is meant to bring a consistent behavior to match HTML's autofocus.

https://html.spec.whatwg.org/multipage/interaction.html#the-autofocus-attribute

The above spec outlines that the first element with autofocus found in the DOM should be the one focused, and the others discarded ("flush autofocus candidates" steps 5.11.1 through 5.11.3).

However, the behavior of React's autoFocus polyfill is to set focus to the last element in the DOM with the attribute.

Ideally React's implementation should match the spec, behavior-wise.

@FunctionDJ
Copy link

I've also been having issues with the polyfill in situations where the native autofocus="true" works as expected. However in my case (a modal with react-bulma), React's autoFocus polyfil doesn't work at all and the focus remains where it was before opening the modal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants