Closed Bug 1630769 Opened 5 years ago Closed 5 years ago

autofocus should use autofocus candidates defined in spec

Categories

(Core :: DOM: UI Events & Focus Handling, defect, P3)

defect

Tracking

()

RESOLVED DUPLICATE of bug 1574435

People

(Reporter: sefeng, Unassigned)

Details

Attachments

(1 file)

Attached file another_autofocus.html

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.

Component: DOM: Core & HTML → DOM: UI Events & Focus Handling

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?

Flags: needinfo?(annevk)
Priority: -- → P3

I indeed missed that line. So I guess we can mark this bug as invalid?

I found there is another bug for update autofocus processing algorithm.

Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: