autofocus should use autofocus candidates defined in spec
Categories
(Core :: DOM: UI Events & Focus Handling, defect, P3)
Tracking
()
People
(Reporter: sefeng, Unassigned)
Details
Attachments
(1 file)
103 bytes,
text/html
|
Details |
Consider the attached snippet, Firefox would try to autofocus the hidden input element first, and it would fail to autofocus the second input element because mAutoFocusElement
was set by the first input element https://searchfox.org/mozilla-central/rev/567b68b8ff4b6d607ba34a6f1926873d21a7b4d7/dom/base/Document.cpp#11770,11776.
In Chrome, the second input element will be correctly focused.
I don't think the first element can be considered focusable because it's not visible.
I think we should align with the spec here, so that we have a list of candidates, then we can focus the correct one. Or at lease we should modify the code to not set mAutoFocusElement
for not focusable element.
Please feel free to close this bug if it's a duplicate.
Updated•5 years ago
|
Comment 1•5 years ago
|
||
https://www.w3.org/TR/html52/sec-forms.html#autofocusing-a-form-control-the-autofocus-attribute
There must not be two elements with the same nearest ancestor autofocus scoping document element that both have the autofocus attribute specified.
I also saw an issue related to the hidden attribute.
https://github.com/whatwg/html/issues/4578
(In reply to Sean Feng [:sefeng] from comment #0)
Consider the attached snippet, Firefox would try to autofocus the hidden input element first, and it would fail to autofocus the second input element because
mAutoFocusElement
was set by the first input element https://searchfox.org/mozilla-central/rev/567b68b8ff4b6d607ba34a6f1926873d21a7b4d7/dom/base/Document.cpp#11770,11776.
I think our code follow the current spec.
Anne, what do you think?
Comment 2•5 years ago
|
||
Correct the latest spec link.
https://html.spec.whatwg.org/multipage/interaction.html#flush-autofocus-candidates
Reporter | ||
Comment 3•5 years ago
|
||
I indeed missed that line. So I guess we can mark this bug as invalid?
Comment 4•5 years ago
|
||
I found there is another bug for update autofocus processing algorithm.
Description
•