autoFocus polyfill deviates from HTML autofocus global attribute spec
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 251k
- Forks
- 51.4k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 53
Description
Based on this comment: https://github.com/facebook/react/issues/11851#issuecomment-351672131, 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the autoFocus polyfill implementation and compare its behavior with the linked HTML autofocus specification. Reproduce a case with multiple autofocus elements and verify that the first element in DOM order receives focus; done means the implementation matches that behavior and the relevant regression coverage passes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100