Skip to content

Same route anchor links only fire once when a hash link is preloaded with data-sveltekit-preload-data #10234

@mattpilott

Description

@mattpilott

Describe the bug

Clicking a link that goes to an anchor on the page works but after you remove the anchor via the page store the link no longer works.

The use case i had was using anchors for modals, modal opens on anchor link and anchor link is removed on modal close.

Reproduction

Here's my original repro

https://stackblitz.com/edit/sveltejs-kit-template-default-qwsbag?file=src%2Froutes%2F%2Bpage.svelte

and here is a different approach that highlights the same issue made by a friend

https://stackblitz.com/edit/sveltejs-kit-template-default-fnttrd?file=src%2Froutes%2F%2Bpage.svelte

Logs

No response

System Info

System:
    OS: macOS 13.4.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 900.20 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.16.0 - /opt/homebrew/opt/node@18/bin/node
    npm: 9.5.1 - /opt/homebrew/opt/node@18/bin/npm
  Browsers:
    Firefox: 114.0.1
    Safari: 16.5.1

Severity

serious, but I can work around it

Additional Information

The only work around atm is to force a page reload on modal close, which is not ideal

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingready to implementplease submit PRs for these issues!router

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions