-
-
Notifications
You must be signed in to change notification settings - Fork 128
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
[Next] Binding to prop ref
is broken for Command.Input in ShadowRoot
#1120
Comments
Related to #828 it seems |
If I understand the code correctly,
|
Ok, if I have a reference to the shadow DOM in question, passing So I would have to pass
Which need to be passed in
Ok,
This seems to be the root of the problem. There is no way that we can pass a custom root node ( As far as I understand the code, simply adding a |
Yes, I'm hesitant to expose it because then I have to expose that prop everywhere or create a global config provider that will be useless but still require me to maintain as soon as
|
The ideal state is that we don't need you to tell us what the root node is because we can get it from the node reference, via an anonymous attachment rather than using the id and doing a |
Going to close this as we're tracking full shadow DOM support over at #828 |
Thanks. Good to know that there will be a fix soon-ish. The attachments approach seems like a good solution. Still, for me waiting isn't a solution, so I will probably manually query or create a pnpm patch |
Describe the bug
I wanted to auto-focus the command menu input when toggling it, but the
autofocus
prop did not seem to work. So instead I tried out focusing the<input>
element manually, using theref
prop. In my project, binding toref
only ever initialised the value tonull
.I guess I could circumvent the issue by querying for the
<input>
, butref
returningnull
does not seem to be intended behavior.On Stackblitz I created 3 variants:
normal
: Mount the command menu component normally:<Menu />
nonShadowTargetEl
: Mount the component programmatically using themount
functionshadowTargetEl
: Mount the component programmatically inside a ShadowRootEach variant binds to the
ref
prop and uses$inspect
to log changes to the console:As you can see, 1 & 2 work as expected, both log the
<input>
element. 3, which is inside a ShadowRoot, does not work.My guess is that
ref
is updated using something likedocument.querySelector
? Despite having 3<input>
elements on screen,document.querySelectorAll("input").length
return2
.Reproduction
https://stackblitz.com/edit/vitejs-vite-szvvwd4b?file=src%2FApp.svelte
Logs
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: