question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

clicking hash link recorded in history twice

See original GitHub issue

Describe the bug

When opening #anchor-a then click a link to #anchor-b, history newly records entries #anchor-a and #anchor-b though #anchor-a is previous location.

Therefore, hisotry looks like:

#anchor-a (initial view)
#anchor-b
#anchor-b (when clicked #anchor-b)
#anchor-c
#anchor-c (when clicked #anchor-c)
#anchor-d
#anchor-d (when clicked #anchor-d)
...

Disabling router by export const router = false; mitigate this issue, so that I think router has some issue around this.

Reproduction

https://stackblitz.com/edit/sveltekit-ivmzya?devtoolsheight=33&file=src/routes/index.svelte

Easily understand by following steps:

  1. Open in New Window in Stackblitz
  2. Clicking anchor links some times
  3. Check a browser history, looks like:
スクリーンショット 2022-01-31 3 59 07

(Also I notified null is oddly appealing on first clicking #anchor-b)

Logs

No response

System Info

# npx envinfo --system --binaries --browsers --npmPackages "{svelte,@sveltejs/*,vite}"
  System:
    OS: macOS 11.4
    CPU: (8) x64 Apple M1
    Memory: 24.88 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.13.2 - ~/.nodebrew/current/bin/node
    Yarn: 1.22.17 - ~/.nodebrew/current/bin/yarn
    npm: 8.1.2 - ~/.nodebrew/current/bin/npm
  Browsers:
    Firefox: 95.0
    Safari: 14.1.1
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.17
    @sveltejs/kit: next => 1.0.0-next.251
    svelte: ^3.46.3 => 3.46.3


### Severity

blocking an upgrade

### Additional Information

_No response_

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
bluwycommented, Feb 1, 2022

Yeah it does look like that this issue causes #3621. cc @vicky1999 in case you’re already working on a fix.

1reaction
benmccanncommented, Feb 17, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

What could be causing a duplicate URL hash in history?
The page loads, during the construction of the app, the hash gets set programatically with dojo/hash twice, first time to "", second time...
Read more >
#GTMtips: Track URL Fragments As Pageviews | Simo ...
How to track dynamic changes to the page URL, especially URL fragments, as individual page views in Google Analytics.
Read more >
Pushing and Popping with the History API - HTML5 Doctor
If one of the hash URLs is used by a modern browser, it uses replaceState to quietly correct the URL.
Read more >
HTML5 History: Clean URLs for Deep-linking Ajax Applications
The problem of deep-linking Ajax applications is usually solved by updating the hash value of the URL. This works nicely because the URL...
Read more >
Blockchain - Wikipedia
A blockchain is a type of distributed ledger technology (DLT) that consists of growing lists of records, called blocks, that are securely linked...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found