Clean up focusing in dialog-closedby-start-open.html#58862
Merged
gsnedders merged 1 commit intoApr 16, 2026
Conversation
gsnedders
approved these changes
Apr 16, 2026
gsnedders
left a comment
Member
There was a problem hiding this comment.
https://whatpr.org/html/10124/interactive-elements.html#close-the-dialog
i.e., from whatwg/html#10124 — that added a tentative test which is at /html/semantics/interactive-elements/the-dialog-element/dialog-close-via-attribute.tentative.html
But either way, this is mostly just changing the test to avoid relying on window.getSelection().addRange(document.createRange()); causing focus in the appropriate place.
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.
This test assumes that setting
open = falsewill run the focus-the-previous-element steps, but the relevant (draft) spec has been changed so that doesn't happen anymore (see step 12 of https://whatpr.org/html/10124/interactive-elements.html#close-the-dialog).Also it seems to assume that the
<dt>is the previously-focused element, but it was never focused in the first place.The reason this test passes currently on Blink is the mysterious
window.getSelection().addRange(document.createRange());which focuses the<dt>(on Gecko, this doesn't focus it… which might be the correct behavior because the range doesn't overlap with it, but who knows — AFAICT the interaction between the Selection API and focus is not very well specified).