Skip to content

Commit d996ef5

Browse files
fix: anchor link is not triggering on the first page load
1 parent 75a2e61 commit d996ef5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/pages/layouts/DocPage.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,16 @@ function DocPage(props) {
1818
});
1919

2020
React.useEffect(() => {
21+
2122
initializeSnackObservers();
23+
//note: @eriveltonelias
24+
// currently on docusaurus v2.0.0-beta.7 when the page loads on the first time
25+
// the anchor links is not working as expected.
26+
const hashId = window.location.hash;
27+
const element = document.getElementById(hashId.split('#').join(''));
28+
if (element) {
29+
element.scrollIntoView();
30+
}
2231

2332
return () => {
2433
removeSnackObservers();

0 commit comments

Comments
 (0)