Skip to content

Commit 5e2e91b

Browse files
author
iropolo
committed
fix: possible merge issue in sidebarItem.vue
1 parent e0fb9d6 commit 5e2e91b

File tree

1 file changed

+32
-42
lines changed

1 file changed

+32
-42
lines changed

apps/dialtone-documentation/docs/.vuepress/theme/components/SidebarItem.vue

Lines changed: 32 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
<dt-button
1515
:id="labelId"
1616
v-bind="attrs"
17+
:to="item.link || undefined"
18+
:active="isActiveLink(item.link, true)"
1719
importance="clear"
1820
kind="muted"
1921
label-class="d-jc-flex-start d-ta-left d-fw-normal"
@@ -23,15 +25,14 @@
2325
'd-w100p dialtone-shell-btn',
2426
{
2527
'd-headline--eyebrow d-fw-semibold d-bgc-transparent d-c-default': !item.link,
26-
'd-btn--active': isActiveLink(isExactActive, item.link, true),
2728
'd-pr16': depth === 1,
2829
},
2930
{
3031
'd-pl48': depth === 1,
3132
},
3233
]"
3334
:data-sidebar-link="item.link"
34-
@click="handleClick($event, listeners, navigate, item.link)"
35+
@click="handleClick($event, listeners, item.link)"
3536
>
3637
{{ item.text }}
3738
<template #endIcon="{ iconSize }">
@@ -55,7 +56,7 @@
5556
}"
5657
>
5758
<li
58-
v-for="subItem in subItems"
59+
v-for="(subItem, index) in subItems"
5960
:key="subItem.text"
6061
>
6162
<sidebar-item
@@ -136,35 +137,29 @@
136137
v-else
137138
class="dt-sidebar-item"
138139
>
139-
<router-link
140-
v-slot="{ navigate, isExactActive }"
141-
:to="item.link ?? ''"
142-
custom
140+
<dt-button
141+
:to="item.link || undefined"
142+
:active="isActiveLink(item.link)"
143+
importance="clear"
144+
kind="muted"
145+
label-class="d-jc-flex-start d-ta-left d-fw-normal"
146+
:size="depth === 0 ? 'lg' : undefined"
147+
:class="[
148+
'd-w100p dialtone-shell-btn',
149+
{
150+
'd-headline--eyebrow d-fw-semibold d-bgc-transparent d-c-default': !item.link,
151+
},
152+
]"
153+
:data-sidebar-link="item.link"
143154
>
144-
<dt-button
145-
importance="clear"
146-
kind="muted"
147-
label-class="d-jc-flex-start d-ta-left d-fw-normal"
148-
:size="depth === 0 ? 'lg' : undefined"
149-
:active="isActiveLink(isExactActive, item.link)"
150-
:class="[
151-
'd-w100p dialtone-shell-btn',
152-
{
153-
'd-headline--eyebrow d-fw-semibold d-bgc-transparent d-c-default': !item.link,
154-
},
155-
]"
156-
:data-sidebar-link="item.link"
157-
@click="navigate"
158-
>
159-
<dt-icon
160-
v-if="depth === 0 && item.icon"
161-
:name="item.icon"
162-
size="400"
163-
class="d-mr12 d-fc-muted"
164-
/>
165-
{{ item.text }}
166-
</dt-button>
167-
</router-link>
155+
<dt-icon
156+
v-if="depth === 0 && item.icon"
157+
:name="item.icon"
158+
size="400"
159+
class="d-mr12 d-fc-muted"
160+
/>
161+
{{ item.text }}
162+
</dt-button>
168163
</li>
169164
</template>
170165

@@ -223,9 +218,10 @@ watch(route, (newRoute) => {
223218
hash.value = newRoute.hash;
224219
});
225220
226-
// isExactActive from the router-link doesn't work with hashes,
227-
// that's why we need to check for the hash if it's a single page
228-
const isActiveLink = (isExactActive, link, isParentButton = false) => {
221+
// isExactActive from router-link doesn't work with hashes,
222+
// that's why we need to check for the hash if it's a single page.
223+
// Now computed from route directly instead of router-link's scoped slot.
224+
const isActiveLink = (link, isParentButton = false) => {
229225
if (!link) return false;
230226
231227
// Check if this is a grouping-only parent (link matches first child)
@@ -243,10 +239,11 @@ const isActiveLink = (isExactActive, link, isParentButton = false) => {
243239
return true;
244240
}
245241
242+
const isExactActive = route.path === link;
246243
return props.isSinglePage ? hash.value === link : isExactActive;
247244
};
248245
249-
function handleClick (event, listeners, navigate, link) {
246+
function handleClick (event, listeners, link) {
250247
const itemKey = props.item.link || props.item.text;
251248
252249
// If we're already on this exact page, just toggle the collapsible
@@ -257,13 +254,6 @@ function handleClick (event, listeners, navigate, link) {
257254
return;
258255
}
259256
260-
// We're NOT on this page, so navigate
261-
if (link && route.path !== link) {
262-
navigate();
263-
// Don't emit toggle - route watcher in Sidebar will handle it
264-
return;
265-
}
266-
267257
// If no link, just toggle
268258
if (!link) {
269259
event.preventDefault();

0 commit comments

Comments
 (0)