Skip to content

Allow blur() after an element becomes non-focusable - #13157

Open
domenic wants to merge 1 commit into
mainfrom
codex/blur-non-focusable
Open

domenic wants to merge 1 commit into
mainfrom
codex/blur-non-focusable

Conversation

@domenic

@domenic domenic commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Remove the focusability check from the unfocusing steps so that blur() can synchronously unfocus an element that has become non-focusable but is still in the current focus chain. For example, hiding a focused textarea's ancestor and then calling blur() should immediately move focus to the viewport, without waiting for focus fixup during update the rendering. This matches Chromium, Gecko, and WebKit.

Discovered while investigating jsdom/jsdom#4431.

  • At least two implementers are interested (and none opposed):
    • Matches existing Chromium, Gecko, and WebKit behavior. All three new subtests pass in Chromium 156.0.8078.4, Firefox 157.0, and Playwright WebKit 26.5.
  • Tests are written and can be reviewed and commented upon at:
  • Implementation bugs are filed:
    • Chromium: N/A, already implemented.
    • Gecko: N/A, already implemented.
    • WebKit: N/A, already implemented.
    • Deno (only for timers, structured clone, base64 utils, channel messaging, module resolution, web workers, and web storage): N/A
    • Node.js (only for timers, structured clone, base64 utils, channel messaging, and module resolution): N/A
  • Corresponding HTML AAM & ARIA in HTML issues & PRs: N/A
  • MDN issue is filed: N/A, too much of an edge-case.
  • The top of this comment includes a clear commit message to use.

(See WHATWG Working Mode: Changes for more details.)


/interaction.html ( diff )

Remove the focusability check from the unfocusing steps so that blur() can synchronously unfocus an element that has become non-focusable but is still in the current focus chain. For example, hiding a focused textarea's ancestor and then calling blur() should immediately move focus to the viewport, without waiting for focus fixup during update the rendering. This matches Chromium, Gecko, and WebKit.

Co-Authored-By: codex <codex@openai.com>
domenic added a commit to jsdom/jsdom that referenced this pull request Oct 30, 2026
Run focus fixup during rendering updates when DOM or CSS changes make the focused area non-focusable, moving focus to the document's viewport through the focusing steps. Schedule this work even without pending animation callbacks or pretendToBeVisual.

Allow element.blur() to release focus immediately after the element becomes non-focusable, following whatwg/html#13157.

Fixes #4431.
Fixes #3029.
Closes #4345.

Co-authored-by: codex <codex@openai.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

1 participant