From f804e7cd5b10841f9b29d994de309abe4ac79145 Mon Sep 17 00:00:00 2001 From: jakubabrzy Date: Tue, 19 Sep 2023 14:43:53 +0200 Subject: [PATCH] apply faq scroll to every page --- src/components/Accordion/Item.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/components/Accordion/Item.tsx b/src/components/Accordion/Item.tsx index 22061eeb..356f0c40 100644 --- a/src/components/Accordion/Item.tsx +++ b/src/components/Accordion/Item.tsx @@ -51,6 +51,13 @@ const AccordionItem = ({ } }); + if (!detailsRef.current.hasAttribute("open")) { + // Push to end of queue to read updated position and scroll to it + setTimeout(() => { + detailsRef.current.scrollIntoView({ behavior: "smooth" }); + }); + } + if (!isHashEnabled) { return; } @@ -58,10 +65,6 @@ const AccordionItem = ({ if (detailsRef.current.hasAttribute("open")) { window.history.replaceState({ hash: undefined }, "", location.pathname); } else { - // Push to end of queue to read updated position and scroll to it - setTimeout(() => { - detailsRef.current.scrollIntoView({ behavior: "smooth" }); - }); window.history.replaceState( { hash: id }, "",