Add mock for Element.scrollIntoView to fix tests.
Signed-off-by: Sydney Achinger <sydneynicoleachinger@spotify.com>
This commit is contained in:
@@ -91,6 +91,8 @@ const configApi = new MockConfigApi({
|
||||
},
|
||||
});
|
||||
|
||||
Element.prototype.scrollIntoView = jest.fn();
|
||||
|
||||
const Wrapper = ({ children }: { children: React.ReactNode }) => {
|
||||
return (
|
||||
<TestApiProvider
|
||||
|
||||
+2
-4
@@ -86,10 +86,8 @@ export const TechDocsReaderPageContent = withTechDocsReaderProvider(
|
||||
const [hashElement] = useShadowRootElements([`[id="${hash.slice(1)}"]`]);
|
||||
|
||||
useEffect(() => {
|
||||
if (hashElement) {
|
||||
if (!isStyleLoading) {
|
||||
hashElement.scrollIntoView();
|
||||
}
|
||||
if (hashElement && !isStyleLoading) {
|
||||
hashElement.scrollIntoView();
|
||||
} else {
|
||||
document?.querySelector('header')?.scrollIntoView();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user