Skip to content

Commit 74a58ef

Browse files
authored
fix(v2): various minor bugs with location hash (#4200)
* fix(v2): various minor bugs with location hash * Fix for disabled hideScroll
1 parent c5d3a86 commit 74a58ef

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

packages/docusaurus-theme-classic/src/theme/Navbar/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function Navbar(): JSX.Element {
8383
'navbar--primary': style === 'primary',
8484
'navbar-sidebar--show': sidebarShown,
8585
[styles.navbarHideable]: hideOnScroll,
86-
[styles.navbarHidden]: !isNavbarVisible,
86+
[styles.navbarHidden]: hideOnScroll && !isNavbarVisible,
8787
})}>
8888
<div className="navbar__inner">
8989
<div className="navbar__items">

packages/docusaurus-theme-classic/src/theme/SkipToContent/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ function SkipToContent(): JSX.Element {
3333
};
3434

3535
useEffect(() => {
36-
programmaticFocus(containerRef.current);
36+
if (!location.hash) {
37+
programmaticFocus(containerRef.current);
38+
}
3739
}, [location.pathname]);
3840

3941
return (

packages/docusaurus-theme-classic/src/theme/hooks/useHideableNavbar.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ const useHideableNavbar = (hideOnScroll: boolean): useHideableNavbarReturns => {
7575
return;
7676
}
7777

78+
if (!location.hash) {
79+
return;
80+
}
81+
7882
isFocusedAnchor.current = true;
7983
}, [location.hash]);
8084

0 commit comments

Comments
 (0)