focus-lock
focus-lock copied to clipboard
Focus breaks on focusable element with shadowRoot
We use a web-component library that has elements that both contains a shadowRoot and expects to receive focus with tabIndex.
getActiveElement
function skips over elements that hold focus and also has a shadowRoot.
I'm not entirely sure how the internals of this library is supposed to work, but after removing the part about shadowRoot from getActiveElement
focus works as expected for us. Perhaps it would need to validate that the element is not focusable as well as having .shadowRoot
property.
To clarify - problem is related to focusable shadow root. But what exactly is not working right? Ie doing X instead of doing Y..
The expected behaviors would be that ids-button
gains focus, but instead focus is reset to the first focusable element.
<button>First</button>
<button>Second</button>
<ids-button>Third</ids-button tabindex="0"> <!-- instead of this gaining focus on tab, the "First" button get's focus. -->
<button>Fourth</button>
hm, the logic right now is "do nothing if focus is inside parent component". If focus is triggered, then ids-button
is not "focusable" in the usual terms.
Worth investigation as this is not just a "bug", but a total blocker for someone.
Thank you! I wish I had more time to investigate this a bit further, but for now we have created a patch that seems to work for us, might break other things, so I don't feel confident in providing a PR. Here is the patch https://gist.github.com/SamuelTilly/70fdbe33e55aafb6cebeba2ae3127ab0
I don't know if the slot element logic is necessary, but I guess it would not hurt either.
This issue has been marked as "stale" because there has been no activity for 2 months. If you have any new information or would like to continue the discussion, please feel free to do so. If this issue got buried among other tasks, maybe this message will reignite the conversation. Otherwise, this issue will be closed in 7 days. Thank you for your contributions so far.
This issue has been marked as "stale" because there has been no activity for 2 months. If you have any new information or would like to continue the discussion, please feel free to do so. If this issue got buried among other tasks, maybe this message will reignite the conversation. Otherwise, this issue will be closed in 7 days. Thank you for your contributions so far.