Skip to content

Commit 3c78e2f

Browse files
committed
fix(NavigationMenu)!: revert new collapsible field
Reverts 2be60cd
1 parent 6887e33 commit 3c78e2f

File tree

4 files changed

+9
-37
lines changed

4 files changed

+9
-37
lines changed

docs/content/3.components/navigation-menu.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ Use the `items` prop as an array of objects with the following properties:
2424
- `tooltip?: TooltipProps`{lang="ts-type"}
2525
- `trailingIcon?: string`{lang="ts-type"}
2626
- `type?: 'label' | 'link'`{lang="ts-type"}
27-
- `collapsible?: boolean`{lang="ts-type"}
2827
- `defaultOpen?: boolean`{lang="ts-type"}
2928
- `open?: boolean`{lang="ts-type"}
3029
- `value?: string`{lang="ts-type"}
@@ -283,7 +282,6 @@ props:
283282
description: 'You can customize components by using the `class` / `ui` props or in your app.config.ts.'
284283
- label: Composables
285284
icon: i-lucide-database
286-
collapsible: false
287285
open: false
288286
children:
289287
- label: defineShortcuts
@@ -300,7 +298,6 @@ props:
300298
to: /composables/use-toast
301299
- label: Components
302300
icon: i-lucide-box
303-
collapsible: false
304301
open: false
305302
to: /components
306303
active: true
@@ -340,10 +337,6 @@ props:
340337
---
341338
::
342339

343-
::tip
344-
You can set the `collapsible: false` property on items with children to prevent them from being collapsible. This allows the item to act as a regular link while still displaying its children in a submenu.
345-
::
346-
347340
### Highlight
348341

349342
Use the `highlight` prop to display a highlighted border for the active item.
@@ -940,7 +933,6 @@ props:
940933
icon: i-lucide-database
941934
tooltip:
942935
text: 'Composables'
943-
collapsible: false
944936
open: false
945937
children:
946938
- label: defineShortcuts
@@ -961,7 +953,6 @@ props:
961953
text: 'Components'
962954
to: /components
963955
active: true
964-
collapsible: false
965956
open: false
966957
children:
967958
- label: Link

src/runtime/components/NavigationMenu.vue

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,6 @@ export interface NavigationMenuItem extends Omit<LinkProps, 'type' | 'raw' | 'cu
4848
* @defaultValue `item-${index}`
4949
*/
5050
value?: string
51-
/**
52-
* Make the item collapsible.
53-
* Only works when `orientation` is `vertical`.
54-
* @defaultValue true
55-
*/
56-
collapsible?: boolean
5751
children?: NavigationMenuChildItem[]
5852
onSelect?(e: Event): void
5953
class?: any
@@ -248,7 +242,7 @@ const lists = computed<NavigationMenuItem[][]>(() =>
248242
:class="ui.linkTrailingBadge({ class: [props.ui?.linkTrailingBadge, item.ui?.linkTrailingBadge] })"
249243
/>
250244

251-
<UIcon v-if="(orientation === 'horizontal' && (item.children?.length || !!slots[(item.slot ? `${item.slot}-content` : 'item-content') as keyof NavigationMenuSlots<T>])) || (orientation === 'vertical' && item.children?.length && item.collapsible !== false)" :name="item.trailingIcon || trailingIcon || appConfig.ui.icons.chevronDown" :class="ui.linkTrailingIcon({ class: [props.ui?.linkTrailingIcon, item.ui?.linkTrailingIcon], active })" />
245+
<UIcon v-if="(orientation === 'horizontal' && (item.children?.length || !!slots[(item.slot ? `${item.slot}-content` : 'item-content') as keyof NavigationMenuSlots<T>])) || (orientation === 'vertical' && item.children?.length)" :name="item.trailingIcon || trailingIcon || appConfig.ui.icons.chevronDown" :class="ui.linkTrailingIcon({ class: [props.ui?.linkTrailingIcon, item.ui?.linkTrailingIcon], active })" />
252246
<UIcon v-else-if="item.trailingIcon" :name="item.trailingIcon" :class="ui.linkTrailingIcon({ class: [props.ui?.linkTrailingIcon, item.ui?.linkTrailingIcon], active })" />
253247
</slot>
254248
</span>
@@ -257,18 +251,17 @@ const lists = computed<NavigationMenuItem[][]>(() =>
257251

258252
<DefineItemTemplate v-slot="{ item, index, level = 0 }">
259253
<component
260-
:is="(orientation === 'vertical' && item.children?.length) ? UCollapsible : NavigationMenuItem"
254+
:is="(orientation === 'vertical' && item.children?.length && !collapsed) ? UCollapsible : NavigationMenuItem"
261255
as="li"
262256
:value="item.value || `item-${index}`"
263257
:default-open="item.defaultOpen"
264-
:disabled="(orientation === 'vertical' && item.children?.length) ? item.collapsible === false : undefined"
265-
:unmount-on-hide="(orientation === 'vertical' && item.children?.length) ? unmountOnHide : undefined"
258+
:unmount-on-hide="(orientation === 'vertical' && item.children?.length && !collapsed) ? unmountOnHide : undefined"
266259
:open="item.open"
267260
>
268261
<div v-if="orientation === 'vertical' && item.type === 'label'" :class="ui.label({ class: [props.ui?.label, item.ui?.label, item.class] })">
269262
<ReuseLinkTemplate :item="item" :index="index" />
270263
</div>
271-
<ULink v-else-if="item.type !== 'label'" v-slot="{ active, ...slotProps }" v-bind="(orientation === 'vertical' && item.children?.length && item.collapsible !== false) ? {} : pickLinkProps(item as Omit<NavigationMenuItem, 'type'>)" custom>
264+
<ULink v-else-if="item.type !== 'label'" v-slot="{ active, ...slotProps }" v-bind="(orientation === 'vertical' && item.children?.length && !collapsed) ? {} : pickLinkProps(item as Omit<NavigationMenuItem, 'type'>)" custom>
272265
<component
273266
:is="(orientation === 'horizontal' && (item.children?.length || !!slots[(item.slot ? `${item.slot}-content` : 'item-content') as keyof NavigationMenuSlots<T>])) ? NavigationMenuTrigger : NavigationMenuLink"
274267
as-child
@@ -314,7 +307,7 @@ const lists = computed<NavigationMenuItem[][]>(() =>
314307
</NavigationMenuContent>
315308
</ULink>
316309

317-
<template v-if="orientation === 'vertical' && item.children?.length " #content>
310+
<template v-if="orientation === 'vertical' && item.children?.length && !collapsed" #content>
318311
<ul :class="ui.childList({ class: props.ui?.childList })">
319312
<ReuseItemTemplate
320313
v-for="(childItem, childIndex) in item.children"

test/components/__snapshots__/NavigationMenu-vue.spec.ts.snap

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -842,23 +842,17 @@ exports[`NavigationMenu > renders with orientation vertical and collapsed correc
842842
<!--v-if-->
843843
</div>
844844
</li>
845-
<li data-state="closed" class="min-w-0" value="item-1"><button type="button" aria-controls="" aria-expanded="false" data-state="closed" class="group relative w-full flex items-center gap-1.5 font-medium text-sm before:absolute before:z-[-1] before:rounded-md focus:outline-none focus-visible:outline-none dark:focus-visible:outline-none focus-visible:before:ring-inset focus-visible:before:ring-2 focus-visible:before:ring-primary flex-row py-1.5 before:inset-y-px before:inset-x-0 text-muted hover:text-highlighted hover:before:bg-elevated/50 transition-colors before:transition-colors px-1.5" data-reka-collection-item=""><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="shrink-0 size-5 text-dimmed group-hover:text-default transition-colors" width="1em" height="1em" viewBox="0 0 16 16"></svg>
845+
<li data-menu-item="" class="min-w-0"><button type="button" class="group relative w-full flex items-center gap-1.5 font-medium text-sm before:absolute before:z-[-1] before:rounded-md focus:outline-none focus-visible:outline-none dark:focus-visible:outline-none focus-visible:before:ring-inset focus-visible:before:ring-2 focus-visible:before:ring-primary flex-row py-1.5 before:inset-y-px before:inset-x-0 text-muted hover:text-highlighted hover:before:bg-elevated/50 transition-colors before:transition-colors px-1.5" data-reka-collection-item=""><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="shrink-0 size-5 text-dimmed group-hover:text-default transition-colors" width="1em" height="1em" viewBox="0 0 16 16"></svg>
846846
<!--v-if-->
847847
<!--v-if-->
848848
</button>
849849
<!--v-if-->
850-
<div class="data-[state=open]:animate-[collapsible-down_200ms_ease-out] data-[state=closed]:animate-[collapsible-up_200ms_ease-out] overflow-hidden" id="reka-collapsible-content-v-1" hidden="" data-state="closed" style="--reka-collapsible-content-height: 0px; --reka-collapsible-content-width: 0px;">
851-
<!---->
852-
</div>
853850
</li>
854-
<li data-state="closed" class="min-w-0" value="item-2"><button type="button" aria-controls="" aria-expanded="false" data-state="closed" class="group relative w-full flex items-center gap-1.5 font-medium text-sm before:absolute before:z-[-1] before:rounded-md focus:outline-none focus-visible:outline-none dark:focus-visible:outline-none focus-visible:before:ring-inset focus-visible:before:ring-2 focus-visible:before:ring-primary flex-row py-1.5 before:inset-y-px before:inset-x-0 text-primary before:bg-elevated px-1.5" data-active="" aria-current="page" data-reka-collection-item=""><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="shrink-0 size-5 text-primary group-data-[state=open]:text-primary" width="1em" height="1em" viewBox="0 0 16 16"></svg>
851+
<li data-menu-item="" class="min-w-0"><button type="button" class="group relative w-full flex items-center gap-1.5 font-medium text-sm before:absolute before:z-[-1] before:rounded-md focus:outline-none focus-visible:outline-none dark:focus-visible:outline-none focus-visible:before:ring-inset focus-visible:before:ring-2 focus-visible:before:ring-primary flex-row py-1.5 before:inset-y-px before:inset-x-0 text-primary before:bg-elevated px-1.5" data-active="" aria-current="page" data-reka-collection-item=""><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="shrink-0 size-5 text-primary group-data-[state=open]:text-primary" width="1em" height="1em" viewBox="0 0 16 16"></svg>
855852
<!--v-if-->
856853
<!--v-if-->
857854
</button>
858855
<!--v-if-->
859-
<div class="data-[state=open]:animate-[collapsible-down_200ms_ease-out] data-[state=closed]:animate-[collapsible-up_200ms_ease-out] overflow-hidden" id="reka-collapsible-content-v-2" hidden="" data-state="closed" style="--reka-collapsible-content-height: 0px; --reka-collapsible-content-width: 0px;">
860-
<!---->
861-
</div>
862856
</li>
863857
</ul>
864858
</div>

test/components/__snapshots__/NavigationMenu.spec.ts.snap

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -842,23 +842,17 @@ exports[`NavigationMenu > renders with orientation vertical and collapsed correc
842842
<!--v-if-->
843843
</div>
844844
</li>
845-
<li data-state="closed" class="min-w-0" value="item-1"><button type="button" aria-controls="" aria-expanded="false" data-state="closed" class="group relative w-full flex items-center gap-1.5 font-medium text-sm before:absolute before:z-[-1] before:rounded-md focus:outline-none focus-visible:outline-none dark:focus-visible:outline-none focus-visible:before:ring-inset focus-visible:before:ring-2 focus-visible:before:ring-primary flex-row py-1.5 before:inset-y-px before:inset-x-0 text-muted hover:text-highlighted hover:before:bg-elevated/50 transition-colors before:transition-colors px-1.5" data-reka-collection-item=""><span class="iconify i-lucide:book-open shrink-0 size-5 text-dimmed group-hover:text-default transition-colors" aria-hidden="true"></span>
845+
<li data-menu-item="" class="min-w-0"><button type="button" class="group relative w-full flex items-center gap-1.5 font-medium text-sm before:absolute before:z-[-1] before:rounded-md focus:outline-none focus-visible:outline-none dark:focus-visible:outline-none focus-visible:before:ring-inset focus-visible:before:ring-2 focus-visible:before:ring-primary flex-row py-1.5 before:inset-y-px before:inset-x-0 text-muted hover:text-highlighted hover:before:bg-elevated/50 transition-colors before:transition-colors px-1.5" data-reka-collection-item=""><span class="iconify i-lucide:book-open shrink-0 size-5 text-dimmed group-hover:text-default transition-colors" aria-hidden="true"></span>
846846
<!--v-if-->
847847
<!--v-if-->
848848
</button>
849849
<!--v-if-->
850-
<div class="data-[state=open]:animate-[collapsible-down_200ms_ease-out] data-[state=closed]:animate-[collapsible-up_200ms_ease-out] overflow-hidden" id="reka-collapsible-content-v-0-0-1" hidden="" data-state="closed" style="--reka-collapsible-content-height: 0px; --reka-collapsible-content-width: 0px;">
851-
<!---->
852-
</div>
853850
</li>
854-
<li data-state="closed" class="min-w-0" value="item-2"><button type="button" aria-controls="" aria-expanded="false" data-state="closed" class="group relative w-full flex items-center gap-1.5 font-medium text-sm before:absolute before:z-[-1] before:rounded-md focus:outline-none focus-visible:outline-none dark:focus-visible:outline-none focus-visible:before:ring-inset focus-visible:before:ring-2 focus-visible:before:ring-primary flex-row py-1.5 before:inset-y-px before:inset-x-0 text-primary before:bg-elevated px-1.5" data-active="" aria-current="page" data-reka-collection-item=""><span class="iconify i-lucide:box shrink-0 size-5 text-primary group-data-[state=open]:text-primary" aria-hidden="true"></span>
851+
<li data-menu-item="" class="min-w-0"><button type="button" class="group relative w-full flex items-center gap-1.5 font-medium text-sm before:absolute before:z-[-1] before:rounded-md focus:outline-none focus-visible:outline-none dark:focus-visible:outline-none focus-visible:before:ring-inset focus-visible:before:ring-2 focus-visible:before:ring-primary flex-row py-1.5 before:inset-y-px before:inset-x-0 text-primary before:bg-elevated px-1.5" data-active="" aria-current="page" data-reka-collection-item=""><span class="iconify i-lucide:box shrink-0 size-5 text-primary group-data-[state=open]:text-primary" aria-hidden="true"></span>
855852
<!--v-if-->
856853
<!--v-if-->
857854
</button>
858855
<!--v-if-->
859-
<div class="data-[state=open]:animate-[collapsible-down_200ms_ease-out] data-[state=closed]:animate-[collapsible-up_200ms_ease-out] overflow-hidden" id="reka-collapsible-content-v-0-0-2" hidden="" data-state="closed" style="--reka-collapsible-content-height: 0px; --reka-collapsible-content-width: 0px;">
860-
<!---->
861-
</div>
862856
</li>
863857
</ul>
864858
</div>

0 commit comments

Comments
 (0)