Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML: Sequential focus navigation with shadow dom #17523

Merged
merged 4 commits into from Aug 15, 2019

Conversation

rakina
Copy link
Contributor

@rakina rakina commented Jun 26, 2019

See whatwg/html#4735 for the spec change.

I used the term "flat tree order" in some variable names and comments, but it isn't defined in the spec so it might be confusing. However I'm not sure what else I can use since "composed tree" is also not in the spec, and "shadow-including tree order" is a little bit different because of slots.

Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

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

Some style nits, but this overall looks good. We may also want to move into shadow-dom/

It would be good to get a second implementers' eye on the setup + expected orders (which are the most important parts of the tests). @rniwa maybe :)

// <div #belowSlot tabindex=-1>
// <div #belowHost tabindex=0>

async_test(async (t) => {
Copy link
Member

Choose a reason for hiding this comment

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

This could be promise_test( and then you wouldn't need t.step or t.done()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

setTabIndex([aboveHost, host, belowHost], 0);
resetFocus();
const expectedOrder = [aboveHost, host, belowHost];
for (let el of expectedOrder) {
Copy link
Member

Choose a reason for hiding this comment

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

Can this be a utility function too? It seems like the loop is the same in all tests.

await assertFocusOrder([aboveHost, host, belowHost]);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

}
}

function navigateFocusForward() {
Copy link
Member

Choose a reason for hiding this comment

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

Can you just use the shared one and then say const focused = shadowRoot.activeElement || document.activeElement afterward?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@rakina
Copy link
Contributor Author

rakina commented Jun 27, 2019

cc @annevk and/or @smaug---- for Firefox?

@@ -69,3 +70,14 @@ function navigateFocusForward() {
return test_driver.send_keys(document.body, "\ue004");
}

function assertFocusOrder(expectedOrder) {
Copy link
Member

Choose a reason for hiding this comment

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

The return new Promise isn't needed here. Just make the whole function async, and then put the loop body inside the function:

async function assertFocusOrder(expectedOrder) {
  let shadowRoot = document.getElementById("host").shadowRoot;
  for (let el of expectedOrder) {
    await navigateFocusForward();
    let focused = shadowRoot.activeElement ? shadowRoot.activeElement : document.activeElement;
    assert_equals(focused, el);
  }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh awesome, thanks :D

@rniwa
Copy link
Contributor

rniwa commented Aug 14, 2019

All but one test (focus-tabindex-order-shadow-zero-delegatesFocus.html) with delegatesFocus set to true pass in WebKit so these tests look good to me. Perhaps we can land all tests which doesn't involve delegatesFocus right now so that we can test coverage on things we ought to have interoperability.

Will ad the delegatesFocus test in the delegatesFocus PR instead (web-platform-tests#18035)
@rakina
Copy link
Contributor Author

rakina commented Aug 15, 2019

All but one test (focus-tabindex-order-shadow-zero-delegatesFocus.html) with delegatesFocus set to true pass in WebKit so these tests look good to me. Perhaps we can land all tests which doesn't involve delegatesFocus right now so that we can test coverage on things we ought to have interoperability.

Yay, thanks for trying it out. I've removed the delegatesFocus test, will move that to #18035.

@rniwa rniwa merged commit 888da5c into web-platform-tests:master Aug 15, 2019
natechapin pushed a commit to natechapin/wpt that referenced this pull request Aug 23, 2019
…#17523)

* HTML: Sequential focus navigation with shadow dom

The delegatesFocus test will be in the delegatesFocus PR (web-platform-tests#18035)
domenic pushed a commit to whatwg/html that referenced this pull request Sep 24, 2019
This defines an explicit list for the document's "sequential focus
navigation order", whose contents are defined to include elements in
shadow trees. Previously the contents of the sequential focus navigation
order were defined mostly implicitly, in the tabindex section.

This also expands the ordering requirements for sequential focus
navigation order to account for shadow trees and slotted elements.

Finally, this has a minor connection to delegatesFocus, in that it
excludes elements that are shadow hosts with delegatesFocus = true from
being focusable areas.

Part of #2013.

Tests: web-platform-tests/wpt#17523
zcorpan pushed a commit to whatwg/html that referenced this pull request Nov 6, 2019
This defines an explicit list for the document's "sequential focus
navigation order", whose contents are defined to include elements in
shadow trees. Previously the contents of the sequential focus navigation
order were defined mostly implicitly, in the tabindex section.

This also expands the ordering requirements for sequential focus
navigation order to account for shadow trees and slotted elements.

Finally, this has a minor connection to delegatesFocus, in that it
excludes elements that are shadow hosts with delegatesFocus = true from
being focusable areas.

Part of #2013.

Tests: web-platform-tests/wpt#17523
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants