Repository navigation
Add the focusreset event - #13050
Open
noamr wants to merge 7 commits into
Open
Add the focusreset event#13050noamr wants to merge 7 commits into
noamr wants to merge 7 commits into
Conversation
noamr
marked this pull request as draft
October 8, 2026 14:55
noamr
marked this pull request as ready for review
October 8, 2026 19:28
noamr
marked this pull request as draft
October 11, 2026 20:40
noamr
force-pushed
the
noamr/focus-reset
branch
from
October 12, 2026 10:10
9de3d82 to
7ac0b1a
Compare
Fire a focusreset event at the Document when the focus fixup in the update the rendering steps resets focus to the viewport, either because the focused area stopped being focusable, or because the focused element was removed (which synchronously resets focus). Fixes #12842.
noamr
force-pushed
the
noamr/focus-reset
branch
from
October 13, 2026 10:32
7ac0b1a to
82ae5e6
Compare
noamr
marked this pull request as ready for review
October 13, 2026 10:48
noamr
force-pushed
the
noamr/focus-reset
branch
from
October 13, 2026 11:23
82ae5e6 to
178f554
Compare
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fire a
focusresetevent at theDocument, if focus was reset to the viewport due to a focused element being removed, and wasn't since restored.The timing of the event is in the mutation observer microtask, together with
slotchangeevents.Together with whatwg/dom#1512
We keep a "has pending focus reset" flag on the document (see the DOM PR) when a focused element is removed, and check it shortly after (in the mutation observer microtask).
The asynchronous check is there to avoid being able to observe intermediate DOM state while removing a node tree.
The firing happens in a microtask rather in the rendering steps to make sure DOM changes in the
focusresethandler are picked up in the next or current render - e.g.focusresetmight be called in the middle of aResizeObservercallback.Fixes #12842.
focusresetmdn/mdn#876(See WHATWG Working Mode: Changes for more details.)
/document-lifecycle.html ( diff )
/dom.html ( diff )
/indices.html ( diff )
/infrastructure.html ( diff )
/interaction.html ( diff )
/webappapis.html ( diff )