-
Notifications
You must be signed in to change notification settings - Fork 378
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
Disabling tabindex across potentially many shadow roots #520
Comments
Did you really intend to file this on the issue tracker for W3C web components specifications? The problem described here seems to be:
|
@rniwa yeah @dglazkov asked me to file it here as part of it relates to Shadow DOM.
To clarify, the issue is there's no easy way to remove an entire shadow tree of elements from the tab order. It's my understanding (though I may be mistaken) that setting tabindex=-1 on the host would not remove the children from the tab order. The animation use case is an example to demonstrate when someone would encounter this issue. |
Now that I think about this, I don't know why we decided |
Yeah, for v0, it was what the spec said, however, we have changed the spec for v1 so that we can skip. @TakayoshiKochi |
I'm not sure what " Without |
I don't understand why interactive elements slows animation. (edit) |
Given, http://w3c.github.io/webcomponents/spec/shadow/#sequential-focus-navigation
and http://w3c.github.io/webcomponents/spec/shadow/#dfn-focus-navigation-order-merging-algorithm
To me, it looks that we do not skip a shadow tree . Step 4 2.2 is always applied, even if the shadow host's tabindex=-1, isn't it? |
I have found that Step3. 1.3 says:
Thus, the spec looks correct to me. |
According to the current spec, a focusable element in a shadow tree whose host's tabindex = -1 is skipped from a sequential focus navigation (by pressing tab-key). However, it does not mention anything that such a focusable element in a shadow tree should be considered 'non-focusable' elements. That's out of the scope in the current spec. To support that, I guess we need another new feature (new attribute?). |
@TakayoshiKochi yes. I was not saying that focusable elements affect performance of animations. I was saying that the only ways I currently know of to disable focus on all elements are either:
If setting tabindex=-1 on a shadow host in shadow dom v1 will remove its children from the tab order then I think I'm happy :) |
Yes, that should be. At least, that's our intention in v1. They are removed from the tab order, but they are still focusable, I think. (Please correct me if I am wrong). Is that okay? Regarding Blink's implementation, let me test the current behavior soon. |
@robdodson did you see whatwg/html#897? This seems similar to that proposal (and that one is not shadow tree specific). |
@hayatoito This mirrors the behaviour for tabindex="-1" in the HTML5.1 spec. It would make sense for tabindex to be consistent with that I think. |
@hayatoito that's good to hear thank you :) @annevk yep I'm on that thread. I think what I'm referring to is a little different, it's closer to the proposed |
I'm working on an offscreen slide-in navigation panel which may contain several focusable elements and needs to animate at 60fps. To achieve the 60fps animation, the drawer has been promoted to a layer using will-change and transformed offscreen. Unfortunately this means all of the focusable children are still interactive.
I could set the drawer to visibility: hidden when it's offscreen (thus fixing the focus issue) but then I'd lose my fancy layer and sacrifice some of my animation perf. On a very large drawer (like the kind on m.facebook.com) this repainting could be very expensive.
An alternative is to do something like:
And loop over all potentially focusable items, setting each to tabindex=-1 when the drawer is offscreen. This may be the faster of the two approaches but it gets difficult if any of those children contain Shadow DOM. Now I need to recurse through each shadow root and again look for either focusable children or more shadow roots.
So there's a few things at play here: how can I remove an entire shadow tree from the tab order? And, if there was such a mechanism, why not let me do it for regular trees as well so I don't need the crazy querySelector string?
cc @alice @paullewis @paulirish
The text was updated successfully, but these errors were encountered: