Skip to content

Commit 4c0846a

Browse files
committed
Fix bug where link/custom-page without anchor is not highlighted
1 parent 10b0702 commit 4c0846a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/zudoku/src/lib/components/navigation/NavigationItem.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ export const NavigationItem = ({
120120
case "link":
121121
case "custom-page": {
122122
const href = item.type === "link" ? item.to : joinUrl(item.path);
123+
const hasAnchor = href.includes("#");
123124
return !href.startsWith("http") ? (
124125
<AnchorLink
125126
to={{
@@ -131,7 +132,9 @@ export const NavigationItem = ({
131132
className={navigationListItem({
132133
isActive:
133134
href ===
134-
[location.pathname, activeAnchor].filter(Boolean).join("#"),
135+
(hasAnchor
136+
? [location.pathname, activeAnchor].filter(Boolean).join("#")
137+
: location.pathname),
135138
})}
136139
onClick={onRequestClose}
137140
>

0 commit comments

Comments
 (0)