Copied from MicrosoftEdge/MSEdgeExplainers#556
@benbeaudry filed originally on 2022-02-23
I'm implementing a prototype of this explainer in Chromium and I'm wondering whether we should allow elements in shadow trees to be part of a focusgroup or not. I couldn't find any mention in the explainer, but I don't see why we shouldn't also include elements hidden within a shadow tree.
WDYT? If you agree, it might be a good idea to mention it in the explainer.
@travisleithead replied
Good point. Insofar as a shadow dom is used to wrap the internals of a logical component, it might makes sense for the host element of that component to declare a focusgroup such that descendents of the focusgroup within the component can take advantage of it. Definitely needs to be described in the explainer/spec.
Perhaps we should piggyback on the existing delegatesFocus flag. If present, then the author of the Shadow Root intends for focus to transition to some sub-component. Therefore, if a focusgroup definition is placed on the host element, then the focusable children (inside the component) should attempt to "link-up" to a cross-shadow-root focusgroup definition in their ancestor "flat tree". Otherwise (the delegatesFocus flag is absent), only elements in that light tree (e.g., those exposed through slots) would be candidates. This may require some clever defintion of the work "children" (e.g., shadow-inclusive children?).
@benbeaudry replied
The "delegatesFocus" flag that already exist is definitely something we could leverage with the focusgroup attribute. However, after some digging, it seems like this flag is only used to redirect the focus event from the ShadowRoot to the first focusable element within the ShadowDOM when the ShadowRoot isn't focusable.
In our situation, the use case would be a bit different: the focus would move from an element outside of the ShadowDOM to an element inside of it on an arrow key press without trying to first go to the ShadowRoot. In my opinion, the delegatesFocus flag is a totally different feature and it doesn't make much sense to piggyback on it because of the different use cases.
I am by no means an expert on the delegatesFocus flag or on ShadowDOMs, so my opinion is to be taken with a grain of salt.
That being said, for the moment, I've decided to allow a focusgroup within a ShadowDOM to extend one that is declared outside of that ShadowDOM in the initial implementation of the focusgroup feature (in Chromium-based browsers). I'll keep monitoring this thread to bring the appropriate changes to the Chromium implementation if needed.
Copied from MicrosoftEdge/MSEdgeExplainers#556
@benbeaudry filed originally on 2022-02-23
@travisleithead replied
@benbeaudry replied