Skip to content

Commit 72569de

Browse files
authored
fix: handle hash navigation to prevent duplicate callbacks (#2575)
1 parent 84ba468 commit 72569de

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

docs/configuration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ If you have a link to the homepage in the sidebar and want it to be shown as act
917917

918918
For more details, see [#1131](https://github.com/docsifyjs/docsify/issues/1131).
919919

920-
## themeColor ⚠️
920+
## themeColor ⚠️ :id=themecolor
921921

922922
!> Deprecated as of v5. Use the `--theme-color` [theme property](themes#theme-properties) to [customize](themes#customization) your theme color.
923923

@@ -931,7 +931,7 @@ window.$docsify = {
931931
};
932932
```
933933

934-
## topMargin ⚠️
934+
## topMargin ⚠️ :id=topmargin
935935

936936
!> Deprecated as of v5. Use the `--scroll-padding-top` [theme property](themes#theme-properties) to specify a scroll margin when using a sticky navbar.
937937

src/core/router/history/hash.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ export class HashHistory extends History {
4747

4848
if (el && el.tagName === 'A' && !isExternal(el.href)) {
4949
navigating = true;
50+
51+
// Do not compare hash containing these classes.
52+
if (['app-name-link', 'page-link'].includes(el.className)) {
53+
return;
54+
}
55+
56+
if (el.hash === location.hash) {
57+
cb({ event: e, source: 'navigate' });
58+
}
5059
}
5160
});
5261

0 commit comments

Comments
 (0)