Skip to content

Commit

Permalink
clean hash from url after close of faq item
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubabrzy committed Sep 18, 2023
1 parent 963912a commit a786235
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/Accordion/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ const AccordionItem = ({ summary, open, children }: AccordionItemProps) => {
}
});

window.location.replace(`${location.pathname}#${encodeURI(summary)}`);
if (decodeURI(location.hash) === `#${summary}`) {
// Hash at the end disables ability to open automaticaly first FAQ item
window.location.replace(`${location.pathname}#`);
} else {
window.location.replace(`${location.pathname}#${encodeURI(summary)}`);
}
};

useEffect(() => {
Expand Down

0 comments on commit a786235

Please sign in to comment.