Skip to content

Commit

Permalink
feat(theme): improve sidebar collapsed state (#377)
Browse files Browse the repository at this point in the history
  • Loading branch information
pengzhanbo authored Dec 14, 2024
1 parent b5ca59d commit a776852
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions theme/src/client/composables/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,9 +400,10 @@ export function useSidebarControl(item: ComputedRef<ResolvedSidebarItem>): Sideb
return !!(item.value.items && item.value.items.length)
})

watchEffect(() => {
collapsed.value = !!(collapsible.value && item.value.collapsed)
})
watch(() => [collapsible.value, item.value.collapsed], (n, o) => {
if (n[0] !== o?.[0] || n[1] !== o?.[1])
collapsed.value = !!(collapsible.value && item.value.collapsed)
}, { immediate: true })

watch(() => [page.value.path, isActiveLink.value, hasActiveLink.value], () => {
if (isActiveLink.value || hasActiveLink.value) {
Expand Down

0 comments on commit a776852

Please sign in to comment.