Skip to content

Clean up focusing in dialog-closedby-start-open.html#58862

Merged
gsnedders merged 1 commit into
web-platform-tests:masterfrom
ltenmoz:fix-dialog-closedby-start-open
Apr 16, 2026
Merged

Clean up focusing in dialog-closedby-start-open.html#58862
gsnedders merged 1 commit into
web-platform-tests:masterfrom
ltenmoz:fix-dialog-closedby-start-open

Conversation

@ltenmoz

@ltenmoz ltenmoz commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

This test assumes that setting open = false will 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).

@ltenmoz ltenmoz requested a review from a team as a code owner March 30, 2026 20:43
@wpt-pr-bot wpt-pr-bot requested review from annevk, foolip, jdm and jgraham March 30, 2026 20:43

@gsnedders gsnedders left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@gsnedders gsnedders merged commit 4be4d67 into web-platform-tests:master Apr 16, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants