Repository navigation
Description
Section 6.5.4 Processing model of the HTML specification defines focusing steps that user agents must immediately run "whenever the user attempts to move the focus" (emphasis mine). The same section also defines a focus fixup rule that specifies the behaviour when the focused area of the document stops being a focusable area. (For example, when an <input type=text> element becomes styled with display: none, it is no longer being rendered and hence no longer meets the requirements to be a focusable area.) I quote the normative part of the rule below:
Focus fixup rule: When the designated focused area of the document is removed from that
Documentin some way (e.g. it stops being a focusable area, it is removed from the DOM, it becomes expressly inert, etc.), designate theDocument's viewport to be the new focused area of the document.
I believe this section and the non-normative notes beneath it have multiple areas of ambiguity:
Firstly, I perceive "removed from that Document in some way" to be a very imprecise use of language, likely to be confused with the concept of connectedness and the spec definition of node is removed from a document. I propose this phrasing should be replaced with a clear term or set of terms that better encompass the examples given in both the rule itself and the first accompanying note.
Secondly, it is ambiguous whether the focus fixup rule requires the focusing steps to be run. In my reading it certainly doesn't explicitly call for it, but if the second accompanying note is taken at face value, this would imply that the value of document.activeElement could change without either a focus or blur event being triggered. I propose that either the focusing steps be amended to mention non-user driven focus changes or the focus fixup rule be amended to state the focusing steps must/must not be called, or both.
In my testing, when a focused input element stopped being rendered, browsers appeared to take inconsistent approaches:
- Chrome ran the focusing steps, designating a new focused area of the document as per step 4.1 of the focus update steps (called for in turn by step 8 of the focusing steps).
- Firefox and Safari neither ran the focusing steps nor designated a new focused area of the document.
In response to that finding, I also opened a corresponding Chrome bug yesterday: https://bugs.chromium.org/p/chromium/issues/detail?id=1214850
Activity
annevk commentedon Jun 2, 2021
cc @rakina @rniwa @smaug----
Make the focus fixup rule more explicit
Make the focus fixup rule more explicit
Make the focus fixup rule more explicit