Skip to content

Commit

Permalink
Auto open when isActivePath is true
Browse files Browse the repository at this point in the history
  • Loading branch information
brookslybrand committed Mar 22, 2024
1 parent aa9b8af commit 54ea196
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/routes/docs.$lang.$ref.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,13 @@ function MenuCategoryDetails({ slug, children }: MenuCategoryDetailsType) {
// By default only the active path is open
const [isOpen, setIsOpen] = React.useState(isActivePath);

// Auto open the details element, useful when navigating from the home page
React.useEffect(() => {
if (isActivePath) {
setIsOpen(true);
}
}, [isActivePath]);

return (
<details
className="group relative flex cursor-pointer flex-col"
Expand Down

0 comments on commit 54ea196

Please sign in to comment.