File tree Expand file tree Collapse file tree 4 files changed +21
-2
lines changed
packages/0/src/composables/createNested Expand file tree Collapse file tree 4 files changed +21
-2
lines changed Original file line number Diff line number Diff line change 6060 if (hasPage (configuredNav .value , path )) return null
6161 return findPage (app .nav , path )
6262 })
63+
64+ // Check if nav has real content (not just dividers)
65+ const hasNavContent = computed (() =>
66+ configuredNav .value .some (item => ! (' divider' in item )),
67+ )
6368 const navRef = useTemplateRef <AtomExpose >(' nav' )
6469
6570 // Match Tailwind's md breakpoint (768px) for nav visibility
180185 </template >
181186
182187 <template v-if =" selectedLevels .size > 0 " >
183- <li class =" px-4" >
188+ <!-- Skip divider if Active page section already added one and nav has no real content -->
189+ <li v-if =" !filteredOutPage || hasNavContent" class =" px-4" >
184190 <AppDivider />
185191 </li >
186192
Original file line number Diff line number Diff line change @@ -89,9 +89,15 @@ export function createNavNested (nav: MaybeRefOrGetter<NavItem[]>) {
8989 const scrollEnabled = shallowRef ( false )
9090
9191 // SSR-safe: Build tree structure on server and client
92+ // Preserve open state across nav changes (e.g., filtering)
9293 watch ( ( ) => toValue ( nav ) , items => {
94+ const savedOpenIds = [ ...nested . openedIds ]
9395 nested . clear ( )
9496 nested . onboard ( navToNestedItems ( items ) )
97+ // Restore any open IDs that still exist in the new tree
98+ if ( savedOpenIds . length > 0 ) {
99+ nested . open ( savedOpenIds . filter ( id => nested . has ( id ) ) )
100+ }
95101 } , { immediate : true } )
96102
97103 // Top-level sections to open on first visit
Original file line number Diff line number Diff line change @@ -588,13 +588,17 @@ export function createNested<
588588 return registrations . map ( registration => register ( registration ) )
589589 }
590590
591- function reset ( ) : void {
591+ function clear ( ) : void {
592592 children . clear ( )
593593 parents . clear ( )
594594 openedIds . clear ( )
595595 group . reset ( )
596596 }
597597
598+ function reset ( ) : void {
599+ clear ( )
600+ }
601+
598602 const context = {
599603 ...group ,
600604 children : children as ReadonlyMap < ID , readonly ID [ ] > ,
@@ -630,6 +634,7 @@ export function createNested<
630634 unregister,
631635 offboard,
632636 onboard,
637+ clear,
633638 reset,
634639 get size ( ) {
635640 return group . size
Original file line number Diff line number Diff line change @@ -164,6 +164,8 @@ export interface NestedContext<Z extends NestedTicket> extends Omit<GroupContext
164164 unregister : ( id : ID , cascade ?: boolean ) => void
165165 /** Offboard multiple nodes, optionally cascading */
166166 offboard : ( ids : ID [ ] , cascade ?: boolean ) => void
167+ /** Clear all nodes and nested state (children, parents, openedIds) */
168+ clear : ( ) => void
167169}
168170
169171/**
You can’t perform that action at this time.
0 commit comments