Skip to content

When must the focusing steps be run? #6729

Closed

Description

@lpd-au

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 Document in some way (e.g. it stops being a focusable area, it is removed from the DOM, it becomes expressly inert, etc.), designate the Document'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

  1. added
    topic: focus
    on Jun 2, 2021
  2. annevk commented on Jun 2, 2021

    @annevk
    Member
  3. added a commit that references this issue on Oct 16, 2022
    14eb00c
  4. added a commit that references this issue on Nov 4, 2022
    c4533d4
  5. added a commit that references this issue on Jan 18, 2023
    6a5109c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: focus

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions