Skip to content

NavigationMenu: expanding a nested item in vertical orientation collapses its parent when using v-model #7215

Description

@IlyaSemenov

Environment

  • Operating System: Darwin
  • Node Version: v24.18.1
  • Nuxt Version: 4.6.1
  • Package Manager: bun@1.4.3
  • @nuxt/ui: 4.10.0
  • reka-ui: 2.10.1
  • vue: 3.5.43

Is this bug related to Nuxt or Vue?

Nuxt

Package

v4.x

Version

v4.10.0

Reproduction

Playground

The same component:

<script setup lang="ts">
import type { NavigationMenuItem } from '@nuxt/ui'

const open = ref(['Parent'])

const items: NavigationMenuItem[] = [{
  label: 'Parent',
  children: [
    { label: 'Page', to: '/page' },
    { label: 'Nested', children: [{ label: 'Child', to: '/child' }] }
  ]
}]
</script>

<template>
  <UNavigationMenu v-model="open" :items="items" orientation="vertical" value-key="label" />
  <pre>{{ open }}</pre>
</template>
  1. Render the component: "Parent" is expanded and shows "Page" and "Nested".
  2. Click "Nested".

Expected: "Nested" expands to show "Child", "Parent" stays expanded, and open stays ["Parent"].

Actual: open becomes ["Nested"], so the top-level accordion collapses "Parent" and the whole subtree disappears, including the "Nested" item that was just clicked.

Description

In a vertical UNavigationMenu with v-model, the nested accordion that renders an item's children emits its own open values through the menu's update:modelValue. The menu's modelValue describes only the top-level accordion (it is bound to the top-level AccordionRoot only), so any interaction with a nested section overwrites the top-level state.

This happens because accordionProps is created with the component's emits:

const accordionProps = useForwardProps(reactivePick(props, 'collapsible', 'disabled', 'type', 'unmountOnHide'), emits)

useForwardProps adds the onUpdate:modelValue listener to the returned object. Both the top-level AccordionRoot and the nested AccordionRoot inside AccordionContent spread ...accordionProps, so the nested root forwards its update:modelValue to the menu as well. The same code is on the current v4 branch.

Without v-model the issue is invisible, because nothing writes the emitted value back into the top-level accordion.

A possible fix is to not forward update:modelValue from nested accordions, for example by overriding the listener in the nested AccordionRoot binding, or by building a separate props object for nested roots without emits. We currently apply the first option as a local patch (below). With it, expanding a nested section keeps the parent open and v-model reflects only top-level sections.

Local patch for @nuxt/ui@4.10.0
diff --git a/dist/runtime/components/NavigationMenu.vue b/dist/runtime/components/NavigationMenu.vue
index 68e624b00eb7d06f99bde9f395c4d9ae18e1030e..5f30ef80db4261fbbd8203f0dfdf69f49d96ae1e 100644
--- a/dist/runtime/components/NavigationMenu.vue
+++ b/dist/runtime/components/NavigationMenu.vue
@@ -271,6 +271,7 @@ function onLinkTrailingClick(e, item) {
         <AccordionRoot
           v-bind="{
   ...accordionProps,
+  'onUpdate:modelValue': void 0,
   defaultValue: getAccordionDefaultValue(item.children, level + 1, listIndex)
 }"
           as="ul"

Activity

  1. added theissue type on Oct 16, 2026
  2. scenerecap commented on Oct 22, 2026

    @scenerecap

    Still reproduces on play.ui.nuxt.com (nuxt/ui v4.12.0, Chromium 151, 2026-10-21):

    1. Open the playground linked in this issue on play.ui.nuxt.com — App.vue has a vertical UNavigationMenu with v-model, Parent is expanded by default showing Page and Nested.
    2. In the preview pane, click Nested.
    3. Parent collapses (children hidden, chevron down); v-model changes from ["Parent"] to ["Nested"] — expected ["Parent", "Nested"].

    Recording with the v-model readout visible throughout: https://scenerecap.com/s/ou5ch6mw3t

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageAwaiting initial review and prioritization

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions