Skip to content

Commit

Permalink
apply faq scroll to every page
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubabrzy committed Sep 19, 2023
1 parent 17f46a5 commit f804e7c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/components/Accordion/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,20 @@ 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;
}

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 },
"",
Expand Down

0 comments on commit f804e7c

Please sign in to comment.