-
Notifications
You must be signed in to change notification settings - Fork 379
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
:focus behavior of delegatesFocus:true will be confusing for users #554
Comments
I'd like to better understand this feature and how we expect folks to use it. Is there a discussion somewhere? As it currently stands, I'm not sure advocating it to developers will be a good idea :\ cc @robdodson @alice |
One idea I had previously was to only match |
Related is the fact that clicking on an element in the Shadow DOM will find the nearest focusable element and apply focus to it. So if I have
And I click the |
cc: @TakayoshiKochi , @sorvell, @sjmiles Yeah, it looks very weird. I remember that we had an internal meeting about how I remember that the motivation of this feature is that users want to use Is there any good idea to fix this? |
What about my idea to only match |
The original idea was If an author uses custom And for So conceptually, the outermost element should be styled as if it were a regular HTML element, The element with I think the problem here is UA stylesheet's |
Here are some references: |
"nearest focusable element" is a bit inaccurate. If delegatesFocus=true, any click event |
Do you mean we should mark this issue WONTFIX unless we have a better proposal? I appreciate a better proposal, if someone has, because "default outline ring around multiple items" is a very bad user experience. Given the current spec, it is not easy to avoid that. I am afraid that a workaround, overwriting UA's stylesheet by author stylesheet, does not always work. |
I don't follow - is there an objection to my proposal? |
Could you elaborate this? I am afraid that I do not understand the point fully. :( |
We might want to update the spec somehow: http://w3c.github.io/webcomponents/spec/shadow/#focus
Does "removing 4 and 5 from the spec" sound good? I am not sure what is the best for us. :( |
Yes, custom elements may be focusable or not. But in my opinion, if the element is not itself focusable, it makes no sense for it to match Two examples:
|
Yeah, we have two use cases, 1) The problem is that there is no hint which tells us 1) or 2). I supposed that |
Supposing a shadow host didn't have any focusable ancestors, how would we determine whether it was a tab stop? Surely the same signal can be used to disambiguate (1) and (2)? |
Per http://w3c.github.io/webcomponents/spec/shadow/#sequential-focus-navigation
A delegatesFocus flag is used as a signal. If its shadow root's delegates flag is not set, it is top-stop-ed. |
But that's for elements already in NAVIGATION-ORDER. How do they get in that set in the first place? |
Ah, good point! I believe "element's tabindex should be set" in the first place. cc: @TakayoshiKochi |
Right, so unless |
Awesome. Your proposal sounds reasonable to me. I support it! We should update 4 and 5 in the spec so that it also considers tabindex-sh. @TakayoshiKochi , could you work on updating the spec? If someone has a concern for this change, please let us know that. |
I would like to clarify expected results for each case:
Suppose that each shadow root has a focusable element, and it is focused, |
I would expect that if |
Thanks.
|
Hmm. per the spec.
I am not sure what "tabindex value" means here if a custom element does not have a tabindex attribute. It is considered zero, or negative? |
If the element has an explicit attribute, use its value, otherwise it has internal value (accessible At this point we don't allow shadow root on any default-focusable elements (e.g. |
What is the default value of an internal value for case 2 and 5? |
For those with explicit (for 2, its shadow root's |
If tabindex value for case 5 is -1, I am afraid that the focusable elements in the shadow tree would not be merged to "document sequential focus navigation order". That looks a bug... :( |
We can fix that as another spec issue. :) That should be an orthogonal issue, I think. |
We already have overloaded meaning for "tabindex" attribute (determine tab order, and making the element focusable), I'm reluctant to add another meaning of "making it match for IMHO we can do either
In the latter case, you lose the ability to make |
Could someone summarize the proposals? Proposal A) keep the status quo.
Proposal B)
Proposal C) (@alice ?)
Is there any other proposal? |
I don't think this actually overrides the meaning of |
Regarding the examples, my proposal would have Focusable is not the same as being in the tab order. If you write My read on I agree it would be great to have a mechanism for making a custom element focusable without an explicit tabindex (and I have given that feedback multiple times), but I think that's orthogonal to this issue. |
Thanks. I guess there are a lot of different opinions on this issue. We should be careful. My understanding of this issue is that:
|
@hayatoito thanks for summarizing the issue.
I am wondering @alice 's Probably for such an element, you can have |
Ah right, thanks for clarifying @TakayoshiKochi! I agree, So I guess I don't completely understand what should happen if a non-focusable element (like in @ebidel's example) has a shadow root attached with It seems like, as specced, I think with the understanding that |
@alice - thanks for the comment, I think we are now on the same page. In my mental model, a shadow host with As you pointed out, Once you are educated, are you happy and can you live with the current |
Yup, the current behaviour now makes sense to me. @ebidel What do you think? Could we come up with a more real-world example for the primer to explain this behaviour in a less confusing way? |
I think a better example would be great, especially one that still maintains how to explain all the nuanced behavior. Open to ideas if anyone has any. |
@ebidel |
Can we expect that a workaround , "disable UA's :focus style for builtin-elements by an author style", always work? It it works, I am okay to close this issue. |
UA stylesheet's From outside: (UA stylesheet is the least precedence in cascading order)
I think it's okay to close the issue. |
Is it guaranteed that UA stylesheet does not use |
Hmm, if UA stylesheet has What is the point of guaranteeing it is overridable even for |
We rely on the UA stylesheet not being overridable for guarantees that are necessary for security and correctness. |
So we cannot close this issue until we have some way to override the focus ring behavior when UA uses I'm not sure whether such use cases happen, and focus ring decoration shouldn't imply any security, so maybe for accessibility correctness? I'm not sure for such cases actually happen, but considering from different angle that the default Here are options I have, in the order of my preference.
As we have a use case for matching @alice @ebidel @robdodson @rniwa @annevk any thoughts? |
That is not my point. We should not provide any way to override UA's !important rule. That's the bottom line. The point is that we should make it clear that there is a case where web developers can not control fully, before closing this issue with the wrong assumption. I prefer the status quo as is, instead of any of 1, 2 or 3. |
Ah, okay, thanks for the clarification. Scratch my few comments above. So does the conclusion below look good? When you specify This can be avoided by giving an explicit style rule like: From outside shadow: When both a component and its user specify the style, their precedence will be determined by shadow cascading rule. CSS Note: whether the style rule like above applies or not follows the rule of cascading, and for a rule in UA stylesheet with |
Let's close this status quo. |
This CL disables the focus delegation when creating a shadow root for devices list to work around an issue with focus being set on a wrong element when clicking some other element [1]. [1] WICG/webcomponents#554 (comment) Bug: 1075414 Change-Id: If5aad7f01a7c13cf095a73c12432661a44e4c771 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2165788 Reviewed-by: Peter Marshall <[email protected]> Reviewed-by: Mathias Bynens <[email protected]> Commit-Queue: Alex Rudenko <[email protected]>
This CL disables the focus delegation when creating a shadow root for devices list to work around an issue with focus being set on a wrong element when clicking some other element [1]. [1] WICG/webcomponents#554 (comment) Bug: 1075414 Change-Id: If5aad7f01a7c13cf095a73c12432661a44e4c771 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2165788 Reviewed-by: Peter Marshall <[email protected]> Reviewed-by: Mathias Bynens <[email protected]> Commit-Queue: Alex Rudenko <[email protected]>
From here:
In practice, this behavior is very confusing. I'm not sure we have an example like it currently in the platform.
Consider http://jsbin.com/kuqepubihi/edit?html,output (Try in Chrome Canary for Custom element support). Tabbing into the
<x-element>
component puts the default outline ring around three items!The text was updated successfully, but these errors were encountered: