From 5a8cbef51747781c5ae20a1f1ae2f968187795f1 Mon Sep 17 00:00:00 2001 From: bendtherules Date: Mon, 26 Oct 2020 17:14:41 +0530 Subject: [PATCH] Accordion - Change scrollRestoration delay to 1sec --- components/Accordion.jsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/components/Accordion.jsx b/components/Accordion.jsx index 5f187b5..795538e 100644 --- a/components/Accordion.jsx +++ b/components/Accordion.jsx @@ -28,9 +28,13 @@ const Accordion = ({ children, title = "More" }) => { // 4. and scroll into view and focus targetElement.focus(); targetElement.scrollIntoView({ block: "center" }); - if ("scrollRestoration" in history) { - history.scrollRestoration = "auto"; - } + // Increased for mobile browsers + const scrollRestorationDelay = 1000; // 1s + setTimeout(() => { + if ("scrollRestoration" in history) { + history.scrollRestoration = "auto"; + } + }, scrollRestorationDelay); } }