Skip to content

Commit d97ed75

Browse files
committed
fix: the current error in the drawer onSelect
1 parent 4b10ffd commit d97ed75

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/components/TheDrawer.vue

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,17 @@ import { useRouter } from "vue-router";
55
66
import { computed, ref } from "vue";
77
8-
// const router = useRouter();
8+
const router = useRouter();
99
const selectedId = ref(0);
1010
1111
const expanded = useLocalStorage("vue-forge-drawer-expanded", true);
1212
const expandedIcon = computed(() =>
1313
expanded.value ? "k-i-arrow-chevron-left" : "k-i-arrow-chevron-right"
1414
);
1515
const items = computed(() => [
16-
{
16+
{
1717
text: "Boards",
1818
icon: "k-i-set-column-position",
19-
selected: true,
2019
data: {
2120
path: "/",
2221
},
@@ -42,10 +41,15 @@ const items = computed(() => [
4241
action: () => (expanded.value = !expanded.value),
4342
},
4443
},
45-
]);
44+
].map((item, index) => ({
45+
...item,
46+
selected: index === selectedId.value,
47+
}))
48+
);
4649
4750
function onSelect({ itemIndex }: { itemIndex: number }) {
4851
const item = items.value[itemIndex];
52+
selectedId.value = itemIndex;
4953
if (item.data.path) router.push(item.data.path);
5054
if (typeof item.data.action === "function") item.data.action();
5155
}

0 commit comments

Comments
 (0)