We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6421eda commit f3d3332Copy full SHA for f3d3332
src/client/app/router.ts
@@ -187,10 +187,13 @@ export function createRouter(
187
search === currentUrl.search
188
) {
189
// scroll between hash anchors in the same page
190
- if (hash && hash !== currentUrl.hash) {
191
- history.pushState(null, '', hash)
192
- // still emit the event so we can listen to it in themes
193
- window.dispatchEvent(new Event('hashchange'))
+ if (hash) {
+ // avoid duplicate history entries when the hash is same
+ if (hash !== currentUrl.hash) {
+ history.pushState(null, '', hash)
194
+ // still emit the event so we can listen to it in themes
195
+ window.dispatchEvent(new Event('hashchange'))
196
+ }
197
// use smooth scroll when clicking on header anchor links
198
scrollTo(link, hash, link.classList.contains('header-anchor'))
199
}
0 commit comments