| Summary: | Implement focus fixup rule | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Tim Nguyen (:ntim) <ntim> |
| Component: | DOM | Assignee: | Ryosuke Niwa <rniwa> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | ahmad.saleem792, emilio, rniwa, webkit-bug-importer |
| Priority: | P2 | Keywords: | InRadar |
| Version: | WebKit Nightly Build | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
|
Description
Tim Nguyen (:ntim)
2022-02-28 06:20:53 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.
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.) Safari TP 151 is still failing these tests: https://wpt.fyi/results/inert/dynamic-inert-on-focused-element.html?label=master&label=experimental&aligned&view=subtest&q=dynamic-inert-on-focused-element Pull request: https://github.com/WebKit/WebKit/pull/6069 Pull request: https://github.com/WebKit/WebKit/pull/9835 Committed 260067@main (71bc5343fd7b): <https://commits.webkit.org/260067@main> Reviewed commits have been landed. Closing PR #9835 and removing active labels. |