Skip to content
This repository has been archived by the owner on Sep 1, 2024. It is now read-only.

Commit

Permalink
Fixed an issue when linking to nested sidebars
Browse files Browse the repository at this point in the history
  • Loading branch information
OdedItkinOW committed Oct 5, 2023
1 parent 554e690 commit 793ef7b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function CategoryItem(
(isCurrentPage ||
// OR auto-collapse is enabled
(autoCollapseCategories &&
// And part the item is part of:
// And part of the item is part of:
// - The active item's path
// It is expanded
(isActiveItem ||
Expand Down Expand Up @@ -137,8 +137,8 @@ function CategoryItem(
const onInteraction = () => setExpand(!expanded);

useEffect(() => {
if (isCurrentPage) setExpand(true);
}, [isCurrentPage, setExpand]);
if (isActiveItem) setExpand(true);
}, [isActiveItem, setExpand]);

// ---------------------------------------------------------------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,27 @@ export default function SidebarLinkHook(
initialHref: string,
path: string,
): {
isMobile: boolean;
collapsed: boolean;
// Is this a parent of the current page
isActiveItem: boolean;
// Is this the current page
isCurrentPage: boolean;
// Is this a link that leads outside the local website?
/** Is this running within a mobile sidebar context */
isMobile: boolean
/** Is this currently contained within a collapsed context */
collapsed: boolean,
/** Is this a parent of the current page */
isActiveItem: boolean,
/** Is this the current page */
isCurrentPage: boolean,
/** Is this a link that leads outside the local website? */
isExternalLink: boolean;
} {
return {
/** Is this running within a mobile sidebar context */
isMobile: useContext(MobileContext),
/** Is this currently contained within a collapsed context */
collapsed: useContext(CollapseContext),
// Is this a parent of the current page
/** Is this a parent of the current page */
isActiveItem: isActiveSidebarItem(item, path),
// Is this the current page
/** Is this the current page */
isCurrentPage: isSamePath(initialHref, path),
// Is this a link that leads outside the local website?
/** Is this a link that leads outside the local website? */
isExternalLink: !(initialHref ? isInternalUrl(initialHref) : true),
};
}

0 comments on commit 793ef7b

Please sign in to comment.