fix(theme): preserve url ?search#hash on navbar version/locale dropdowns navigations (#8059)

This commit is contained in:
Sébastien Lorber 2022-09-07 19:36:04 +02:00 committed by GitHub
parent 67c692326b
commit a492025cbf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 3 deletions

View file

@ -62,7 +62,13 @@ export function useHideableNavbar(hideOnScroll: boolean): {
return;
}
if (locationChangeEvent.location.hash) {
// See https://github.com/facebook/docusaurus/pull/8059#issuecomment-1239639480
const currentHash = locationChangeEvent.location.hash;
const currentHashAnchor = currentHash
? document.getElementById(currentHash.substring(1))
: undefined;
if (currentHashAnchor) {
isFocusedAnchor.current = true;
setIsNavbarVisible(false);
return;