Add path to dependency array to fix FireFox issue.

Signed-off-by: Sydney Achinger <sydneynicoleachinger@spotify.com>
This commit is contained in:
Sydney Achinger
2023-10-20 14:58:51 -04:00
parent eb1a28276d
commit 8ff165a2b5
@@ -81,19 +81,22 @@ export const TechDocsReaderPageContent = withTechDocsReaderProvider(
setShadowRoot,
} = useTechDocsReaderPage();
const dom = useTechDocsReaderDom(entityRef);
const path = window.location.pathname;
const hash = window.location.hash;
const isStyleLoading = useShadowDomStylesLoading(dom);
const [hashElement] = useShadowRootElements([`[id="${hash.slice(1)}"]`]);
useEffect(() => {
if (isStyleLoading) return;
if (hash) {
if (hashElement && !isStyleLoading) {
if (hashElement) {
hashElement.scrollIntoView();
}
} else {
document?.querySelector('header')?.scrollIntoView();
}
}, [hash, hashElement, isStyleLoading]);
}, [path, hash, hashElement, isStyleLoading]);
const handleAppend = useCallback(
(newShadowRoot: ShadowRoot) => {