Skip to content
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 - events lost after action update #9565

Closed
proof-llc opened this issue Nov 20, 2023 · 5 comments
Closed

Svelte 5 - events lost after action update #9565

proof-llc opened this issue Nov 20, 2023 · 5 comments
Milestone

Comments

@proof-llc
Copy link

proof-llc commented Nov 20, 2023

Describe the bug

A lot of bugs in melt-ui have been fixed - there's just one left. It occurs when we run:

const {
  actions: { portal }
} = createToaster();

<div use:portal>
  <button on:click={() => console.log('THIS DOES NOT RUN IN SVELTE 5')}>INSIDE PORTAL </button>
</div>

portal is using svelte/actions. i have removed melt-ui and was able to replicate using actions directly.

Reproduction

Logs

No errors or warnings displayed

System Info

System:
    OS: macOS 14.1
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 21.2.0 - /usr/local/bin/node
    Yarn: 1.22.18 - /opt/homebrew/bin/yarn
    npm: 9.6.7 - /opt/homebrew/bin/npm
    pnpm: 8.10.5 - /usr/local/bin/pnpm
    bun: 1.0.2 - ~/.bun/bin/bun
  Browsers:
    Chrome: 119.0.6045.159
    Chrome Canary: 120.0.6089.3
    Safari: 17.1
    Safari Technology Preview: 17.4
  npmPackages:
    svelte: 5.0.0-next.8 => 5.0.0-next.8

Severity

blocking an upgrade

@proof-llc
Copy link
Author

issue persists with 5.0.0-next.9

@kuechlerm
Copy link

This is also a huge blocker for the migration of ... all my apps.
I use this action for a Portal

function portal(node: HTMLElement) {
		function update() {
			document.body.appendChild(node);
			node.hidden = false;
		}

		function destroy() {
			if (node.parentNode) {
				node.parentNode.removeChild(node);
			}
		}

		update();

		return {
			update,
			destroy,
		};
	}
<div use:portal hidden>
	<slot />
</div>

(The usage is the same as above)

I cannot reproduce the error in the REPL

@proof-llc
Copy link
Author

I also cannot reproduce in the REPL (not sure why - here's my version of it) but when running locally with pnpm dev it doesn't work.

@kuechlerm
Copy link

kuechlerm commented Nov 22, 2023

Using the new snippets and @render stuff instead of a slot, I also get no error in the REPL.

Update: It does not cause the error anymore but the basic problem is still there.

I created a minimal repo: https://github.com/kuechlerm/portal_error

But I get an error in my local dev environment:

ERR_SVELTE_HYDRATION_MISMATCH: Hydration failed because the initial UI does not match what was rendered on the server. TypeError: Illegal invocation
at Module.sibling (operations.js:206:40)
at +page.svelte:13:22
at Portal.svelte:21:19
at render.js:3171:3
at execute_signal_fn (runtime.js:287:67)
at execute_effect (runtime.js:427:29)
at schedule_effect (runtime.js:509:3)
at internal_create_effect (runtime.js:1138:3)
at render_effect (runtime.js:1253:9)
at Module.snippet_effect (render.js:3170:2)

@benmccann benmccann added this to the 5.0 milestone Nov 24, 2023
@dummdidumm
Copy link
Member

Closing as duplicate of #9777 which was fixed already

@dummdidumm dummdidumm closed this as not planned Won't fix, can't repro, duplicate, stale Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants