-
Notifications
You must be signed in to change notification settings - Fork 392
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
this.template.activeElement is not set when focusing markup injected by slot #1923
Comments
The fact that IMO, we should stick to the standard material here and not add APIs |
@pmdartus thanks for the detailed response - that works for me. I wasn't even aware of the |
I think it's fine to expose |
Since this method would give access to the owner document or shadow root, this might have some implications from Locker's perspective. @manuel-jasso @caridy what do you think about this? |
The rules for Locker blocking access to In current prod Locker the rules vary by namespace (I can check details if necessary), so the fix you're proposing might work. But in vNext currently we're planning to disallow access to all of the |
If we were to block access to the root node, what would be our stance regarding this specific issue @manuel-jasso? While it's not common, there are still valid cases for accessing the root node. |
You make a valid point @pmdartus, real world use cases like this are helpful for us to shape Locker vNext. Our goal is "secure by default" which means we want to prevent accidental security anti-patterns, but we know there are valid use cases and maybe we need to have some configs available to allow certain things, but make it very explicit and intentional. I will make sure the @salesforce/ui-security team keeps this use case in mind as we continue with our design. |
I believe |
Do you think we should tap on the newly introduced |
@pmdartus the idea for vnext is to not have to deal with that, but the problem is not about how to touch the dom, but how you interact with the component instance, which locker vnext doesn't do much today. |
Is there a new workaround for getting the |
Description
Slot markup follows special rules in relation to the Shadow DOM:
Unfortunately, there is no corresponding tracking for focused elements when the focused elements are passed in by slot; there is no
this.activeElement
, for example, which only returns focused elements that are part of slot-passed-in markup.Steps to Reproduce
I've included a sandboxed repro below:
https://developer.salesforce.com/docs/component-library/tools/playground/WXAr7bdAW/12/edit
This is the specific bit that ends up being problematic:
If, for example, the snippet is updated to use
focusableElems[1].focus()
, thenthis.template.activeElement
is immediately set.Expected Results
Either
this.template.activeElement
tracks all markup, independent of whether it is part of the component's Shadow DOM, or an alternative means of tracking focus for injected markup is made available.Actual Results
this.template.activeElement
returnsnull
when markup injected via slot is focused, and there is no alternative means to track selected elements.Version
Possible Solution
I'd like to hear thoughts on also exposing an
activeElement
property on the component itself, which will act just like thetemplate
version ofactiveElement
while maintaining the existing separation of concerns that has already been built into distinguishing between component-owned markup versus what's being passed in.Related to: WICG/webcomponents#358 and WICG/webcomponents#479
The text was updated successfully, but these errors were encountered: