Skip to content

Svelte 5: clicks not working inside portal related code in sveltekit #9777

@amit13k

Description

@amit13k

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.

<script>
	const action = (node) => {
		document.body.appendChild(node);

		return {
			destroy() {
				document.body.removeChild(node);
			}
		};
	};
</script>

<div use:action>
	<button on:click={() => console.log(`clicking`)}>on:click</button>
</div>

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

System:
    OS: macOS 14.2
    CPU: (12) arm64 Apple M2 Pro
    Memory: 211.48 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 21.2.0 - /opt/homebrew/bin/node
    Yarn: 1.22.21 - /opt/homebrew/bin/yarn
    npm: 10.2.4 - /opt/homebrew/bin/npm
    pnpm: 8.11.0 - ~/Library/pnpm/pnpm
    bun: 1.0.3 - ~/.bun/bin/bun
  Browsers:
    Chrome: 119.0.6045.199
    Chrome Canary: 121.0.6167.0
    Safari: 17.2

Severity

blocking an upgrade

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions