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

[Link Preview] Lost Anchor After Remounting Trigger #1060

Closed
anatolzak opened this issue Mar 5, 2024 · 0 comments · Fixed by #1053 or #1126 · May be fixed by dev-komenzar/melt-ui#1 or patooworld/novel#3
Closed

[Link Preview] Lost Anchor After Remounting Trigger #1060

anatolzak opened this issue Mar 5, 2024 · 0 comments · Fixed by #1053 or #1126 · May be fixed by dev-komenzar/melt-ui#1 or patooworld/novel#3
Labels
bug Something isn't working

Comments

@anatolzak
Copy link
Contributor

Describe the bug

If you unmount the link preview trigger without unmounting createLinkPreview(), and then remount the trigger, when you try to open the content, the content shows up at the top left of the page

Screen.Recording.2024-03-05.at.1.40.20.PM.mov

The reason for this is that we only set the activeTrigger on createLinkPreview mount, but activeTrigger should be set when the trigger mounts in the trigger action, which would rerun every time a new trigger is mounted, making sure we always have a reference to the up-to-date trigger.

And the reason the content shows up at the top left of the page, is because activeTrigger is still holding a reference to an html element that was unmounted. But even though it was unmounted, it's still technically a valid element but with a client rect of { top: 0, left: 0, width: 0, height: 0 } hence why the content is showing up at the top left of the page.

This is solved in the following PR #1053

Reproduction

https://github.com/anatolzak/melt-ui-link-preview-unmount-bug/blob/main/src/routes/+page.svelte

https://melt-ui-link-preview-unmount-bug.vercel.app/

Logs

No response

System Info

System:
    OS: macOS 14.3
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 118.32 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.9.0 - ~/.nvm/versions/node/v20.9.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v20.9.0/bin/yarn
    npm: 10.1.0 - ~/.nvm/versions/node/v20.9.0/bin/npm
    pnpm: 8.11.0 - /usr/local/bin/pnpm
    bun: 1.0.22 - ~/.bun/bin/bun
  Browsers:
    Brave Browser: 122.1.63.161
    Chrome: 120.0.6099.109
    Edge: 114.0.1823.82
    Safari: 17.3
  npmPackages:
    @melt-ui/svelte: ^0.75.2 => 0.75.2 
    @sveltejs/kit: ^2.0.0 => 2.5.2 
    svelte: ^4.2.7 => 4.2.12

Severity

annoyance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment