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: Portal action "Move to body" finding first "PortalTarget" (might only be a docs issue) #437

Closed
techniq opened this issue Jul 14, 2024 · 0 comments

Comments

@techniq
Copy link
Owner

techniq commented Jul 14, 2024

While investigating sveltejs/svelte#12427 (comment) I noticed in Svelte 5 the "Move to body" basic example does not move to the body but instead finds the first .PortalTarget in the DOM via document.querySelector('.PortalTarget').

Svelte 4

CleanShot.2024-07-14.at.14.48.43.mp4

Svelte 5

CleanShot.2024-07-14.at.14.48.13.mp4

This was surprising, but more to why Svelte 4 doesn't see the subsequent .PortalTarget elements until I added a debugger right after the document.querySelector call and then it became clear.

Svelte 4 Svelte 5
image image

What's even more surprising is I wasn't able to replicate this timing in a Svelte 4 REPL (thus far).

I feel like the Svelte 5 approach works as you would intend, but will be require a change to the docs to set an explicit document.body fallback since the page includes a lot of .PortalTarget examples.

This also did not highlight the main issue of removing subsequent DOM elements. I thought the destroy's removeChild(...) was maybe removing the wrong node but even commenting out the call still destroys the wrong elements.

techniq added a commit that referenced this issue Jul 14, 2024
…pecific explicit `target: document.body`. Resolves #437
@techniq techniq closed this as completed Jul 14, 2024
techniq added a commit that referenced this issue Jul 15, 2024
…pecific explicit `target: document.body`. Resolves #437
techniq added a commit that referenced this issue Jul 15, 2024
…pecific explicit `target: document.body`. Resolves #437
techniq added a commit that referenced this issue Jul 15, 2024
…pecific explicit `target: document.body`. Resolves #437
techniq added a commit that referenced this issue Jul 15, 2024
…pecific explicit `target: document.body`. Resolves #437
techniq added a commit that referenced this issue Jul 30, 2024
…pecific explicit `target: document.body`. Resolves #437
techniq added a commit that referenced this issue Jul 30, 2024
…pecific explicit `target: document.body`. Resolves #437
techniq added a commit that referenced this issue Jul 31, 2024
…pecific explicit `target: document.body`. Resolves #437
techniq added a commit that referenced this issue Jul 31, 2024
…pecific explicit `target: document.body`. Resolves #437
techniq added a commit that referenced this issue Aug 5, 2024
…pecific explicit `target: document.body`. Resolves #437
techniq added a commit that referenced this issue Aug 5, 2024
…pecific explicit `target: document.body`. Resolves #437
techniq added a commit that referenced this issue Aug 6, 2024
…pecific explicit `target: document.body`. Resolves #437
techniq added a commit that referenced this issue Oct 18, 2024
…pecific explicit `target: document.body`. Resolves #437
techniq added a commit that referenced this issue Oct 20, 2024
* Update `svelte` and `vite-plugin-svelte` to latest next (svelte 5)

* Disable sveld until Svelte 5 compatible

* Work around action timing change in Svelte 5 by updating example to specific explicit `target: document.body`.  Resolves #437

* Update `svelte` and `vite-plugin-svelte` to latest next (`.201` and `.5` respectively)

* Update dependencies to latest

* fix(TextField): Type error

* fix(TableOfContents): Fix ssr support

* fix(SelectField): Fix ssr support by no longer nesting `<button>` instances

* Update to official Svelte 5

* Ignore warning

* docs: Remove API docs until can be extracted in Svelte 5 compatible way (sveld update, etc)

* Require official Svelte 5 (instead of `next` version).  Still supports Svelte 3/4

* Add missing changesets

* fix(AppLayout): Fix SSR drawer layout on mobile.  Resolves #22

* refactor: Use 'esm-env' for browser/dev conditionals
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

1 participant