autofocus not work when the element is added to the DOM after the document is done loading (e.g. in window.onload)
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
Webcompat Priority | P3 |
People
(Reporter: philip.npc, Unassigned)
References
(Blocks 1 open bug)
Details
(Whiteboard: [webcompat])
Reporter | ||
Updated•14 years ago
|
![]() |
||
Comment 1•14 years ago
|
||
Updated•14 years ago
|
Comment 2•14 years ago
|
||
Updated•14 years ago
|
Comment 3•14 years ago
|
||
Comment 4•14 years ago
|
||
Comment 5•14 years ago
|
||
Comment 6•14 years ago
|
||
Comment 7•14 years ago
|
||
Comment 8•14 years ago
|
||
Comment 9•12 years ago
|
||
Comment 12•11 years ago
|
||
Comment 13•10 years ago
|
||
Comment 14•7 years ago
|
||
Comment 15•7 years ago
|
||
![]() |
||
Updated•7 years ago
|
![]() |
||
Updated•7 years ago
|
Comment 16•7 years ago
|
||
Here is a real-world example of this bug:
Description: "Enter a movie title" search input box is not auto-focused in Firefox
Steps to Reproduce:
EXPECTED RESULT:
The "Enter a movie title" search input box should be auto-focused like it is in Chrome, Edge, and IE11 on Windows and in Chrome and Safari on macOS.
ACTUAL RESULT:
The search input box is NOT auto-focused in Firefox on Windows or macOS.
Comment 17•6 years ago
|
||
Migrating Webcompat whiteboard priorities to project flags. See bug 1547409.
Comment 18•6 years ago
|
||
See bug 1547409. Migrating whiteboard priority tags to program flags.
Updated•6 years ago
|
Comment 19•6 years ago
|
||
Reverting spam.
![]() |
||
Updated•6 years ago
|
![]() |
||
Comment 20•6 years ago
|
||
Olli, do you know who might want to look at aligning autofocus stuff with other browsers?
Comment 21•6 years ago
|
||
(In reply to Boris Zbarsky [:bzbarsky] from comment #20)
Olli, do you know who might want to look at aligning autofocus stuff with other browsers?
I will follow this up.
Updated•5 years ago
|
Updated•5 years ago
|
![]() |
||
Updated•4 years ago
|
Updated•4 years ago
|
Comment 23•4 years ago
|
||
I just want to point out that autofocus has two separate effects: It focuses an element, AND SCROLLS IT INTO VIEW.
It seems to me that even if (for whatever reason) you can't honor the first of these, the second should still take place. (e.g. if it's in an iframe, and the parent page has the focus).
For an example of why this can be important, I have a (private) website with some quite long forms on it. When there's an error on one of the fields after submit, the form is re-displayed to the user with the error field highlighted and autofocus'ed. The scroll behaviour of autofocus is expected to make the errant field visible on load, if it's initially below the visible viewport area, even in the absence of javascript.
(As it doesn't work in iframes, I use the obvious workaround of using a fragment identifier as well, but this has the undesirable consequence of leaving the fragment identifier in the window history: autofocus would be better. Using a fragment identifier also involves checking the element for an ID that can be used, and insterting one if there isn't already one... it's not necessarily trivial).
Updated•3 years ago
|
Description
•