Skip to content

Commit

Permalink
Migrate focus handling logic from <popup> to Element [popup 7/7]
Browse files Browse the repository at this point in the history
This moves the focus management stuff out of HTMLPopupElement and into
Element, to work with both <popup> and <div popup>.

With this CL, all of the WPTs now pass, with the exception of the one
for the anchor IDL property, which is an open issue [1].

[1] openui/open-ui#382

Bug: 1307772
Change-Id: I0f475b52b1a14a910d267c7b681327f2e08976ac
Cq-Do-Not-Cancel-Tryjobs: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3561291
Reviewed-by: David Baron <dbaron@chromium.org>
Auto-Submit: Mason Freed <masonf@chromium.org>
Commit-Queue: David Baron <dbaron@chromium.org>
Cr-Commit-Position: refs/heads/main@{#988069}
  • Loading branch information
mfreed7 authored and chromium-wpt-export-bot committed Apr 1, 2022
1 parent 82bcde5 commit 7e58a49
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions html/semantics/popups/popup-focus.tentative.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
<button>first button</button>
</div>

<div popup=popup data-test='autofocus popup' autofocus class=should-be-focused>
<div popup=popup data-test='autofocus popup' autofocus tabindex=-1 class=should-be-focused>
<p>This is a popup</p>
</div>

<div popup=popup data-test='autofocus empty popup' autofocus class=should-be-focused></div>
<div popup=popup data-test='autofocus empty popup' autofocus tabindex=-1 class=should-be-focused></div>

<div popup=popup data-test='autofocus popup with button' autofocus class=should-be-focused>
<div popup=popup data-test='autofocus popup with button' autofocus tabindex=-1 class=should-be-focused>
<p>This is a popup</p>
<button>button</button>
</div>
Expand All @@ -38,7 +38,7 @@
<button autofocus>second autofocus button</button>
</div>

<div popup=popup autofocus data-test='autofocus popup and multiple autofocus children' class=should-be-focused>
<div popup=popup autofocus tabindex=-1 data-test='autofocus popup and multiple autofocus children' class=should-be-focused>
<p>This is a popup</p>
<button autofocus>autofocus button</button>
<button autofocus>second autofocus button</button>
Expand Down Expand Up @@ -129,14 +129,14 @@
button.remove();
});
popup.id = popupId;
button.setAttribute('popup', popupId);
button.setAttribute('triggerpopup', popupId);
priorFocus.focus();
button.click();
assert_equals(document.activeElement, expectedFocusedElement, `${testName} activated by button.click()`);

// Make sure we can directly focus the (already open) popup:
popup.focus();
assert_equals(document.activeElement, popup.hasAttribute('delegatesfocus') ? expectedFocusedElement : popup, `${testName} directly focus with popup.focus()`);
assert_equals(document.activeElement, popup.hasAttribute('tabindex') ? popup : expectedFocusedElement, `${testName} directly focus with popup.focus()`);
popup.hidePopup();
}, "Popup focus test: " + testName);
}
Expand Down

0 comments on commit 7e58a49

Please sign in to comment.