RESOLVED FIXED 237273
Implement focus fixup rule
https://bugs.webkit.org/show_bug.cgi?id=237273
Summary Implement focus fixup rule
Tim Nguyen (:ntim)
Reported 2022-02-28 06:20:53 PST
https://html.spec.whatwg.org/multipage/interaction.html#focus-fixup-rule 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 inert, etc.), designate the Document's viewport to be the new focused area of the document.
Attachments
Tim Nguyen (:ntim)
Comment 1 2022-02-28 06:38:28 PST
Adding this seems to work: ``` if (auto* activeElement = document.activeElement()) { if (!activeElement->isFocusable()) document.setFocusedElement(nullptr); } ``` I put it in the RenderingUpdateStep::FlushAutofocusCandidates block, but that's probably not the right place (not sure which one is?). One thing that's broken is interaction with shadow DOM: shadow-dom/focus/focus-pseudo-on-shadow-host-1.html fails. This is precisely because activeElement->isFocusable() doesn't take in account contents of the shadow DOM, and wrongly clears focus in this case. Though I expect that's not too hard to fix.
Tim Nguyen (:ntim)
Comment 2 2022-02-28 06:40:04 PST
imported/w3c/web-platform-tests/inert/dynamic-inert-on-focused-element.tentative.html tests this functionality. I'm actually a bit surprised there aren't more tests (e.g. moving out of a focusable area, disabled attribute, etc.)
Radar WebKit Bug Importer
Comment 3 2022-03-07 06:21:13 PST
Tim Nguyen (:ntim)
Comment 5 2022-11-02 18:51:55 PDT
Ryosuke Niwa
Comment 6 2023-02-08 13:35:55 PST
EWS
Comment 7 2023-02-09 09:46:51 PST
Committed 260067@main (71bc5343fd7b): <https://commits.webkit.org/260067@main> Reviewed commits have been landed. Closing PR #9835 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.