From aae0a1420caf17bb87249c988c735be5d5ae5c8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Chalifour?= Date: Mon, 8 Jun 2020 15:46:17 +0200 Subject: [PATCH] fix(docsearch): use `scrollTo` when unmounting modal --- packages/docsearch-react/src/DocSearchModal.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/docsearch-react/src/DocSearchModal.tsx b/packages/docsearch-react/src/DocSearchModal.tsx index fad69a22c..e5cf2da32 100644 --- a/packages/docsearch-react/src/DocSearchModal.tsx +++ b/packages/docsearch-react/src/DocSearchModal.tsx @@ -279,7 +279,9 @@ export function DocSearchModal({ return () => { document.body.classList.remove('DocSearch--active'); - document.body.scrollTop = scrollY.current; + // IE11 doesn't support `scrollTo` so we check that the method exists + // first. + window.scrollTo?.(0, scrollY.current); }; }, []);