-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Svelte 5: clicks not working inside portal related code in sveltekit #9777
Comments
This is the intended behaviour as Svelte 5 attaches events via delegation to the root. Furthermore, this approach will likely cause issues with the entire Svelte runtime if done this way (as we use DOM template cloning and walking), so I definitely wouldn't recommend or endorse this pattern. Maybe we need some native way of portaling in Svelte 5. However, that is a bigger discussion. |
I suspect that this sort of thing is being used a lot, though, so it might be pretty important to make this work (see also #1133, #7082 and svelte-portal). Personally, I have at least one project where a portal action is used to move a dialog to the |
@brunnerh It would be interesting to see how far we can push people to use the |
It would be for the better but people would not be pleased 😅. Incidentally I thought about migrating a |
I'd argue it's not that simple, especially when it's more limited when it comes to styling. More importantly though, portalling is not limited to dialog elements. E.g. in Melt UI, we use portal for a lot of elements that require absolute positioning (e.g. Select, Combobox, Popover, etc), which is a common use-case in frameworks to avoid stacking context issues. Not having any form of portalling enabled, be it in user-land or outside, is a big problem, especially for component libraries. |
Came here to say exactly what @TGlide said! |
Using |
<button on:click>
{@render children()}
</button> and then <TextButton on:click={closeDialog}>
close
</TextButton> not sure if it helps but you can reproduce this issue with melt-ui: sveltelab example |
Are there any news on this one ? I am facing the same issue atm As for DX, being able to manipulate directly the DOM nodes without having to worry about the framework has a big appeal at least for me personally, having to use an internal portal utility surely would solve the problem but would make it harder to integrate with existing js only libraries I suppose (?) |
Not sure if this will help y'all but I published another This will let you also render components as child, and keep events, etc etc |
Describe the bug
When using svelte 5 with sveltekit, clicks inside div that use portal related action don't seem to work. Clicks do work with Svelte 4 with the same code.
Is this the intended behavior ? I encountered this when clicks were not working on buttons inside sheet component of shadcn-svelte.
Also, this issue doesn't occur in svelte-5 repl, so not sure if this is svelte 5 issue.
Reproduction
Svelte 5 Reproduction with the problem
The click handlers do not execute with Svelte 5.
Svelte 4 Reproduction without this problem
With Svelte 4, messages do appear on the browser console.
Svelte 5 REPL without this problem
Confused about why this issue doesn't occur in the REPL
Logs
No response
System Info
Severity
blocking an upgrade
The text was updated successfully, but these errors were encountered: