Skip to content

defineShortcuts: Wrong handling of key sequences #5654

@niusia-ua

Description

@niusia-ua

Environment

  • Operating System: Windows_NT
  • Node Version: v24.4.1
  • Nuxt Version: 4.2.1
  • CLI Version: 3.30.0
  • Nitro Version: 2.12.9
  • Package Manager: [email protected]
  • Builder: -
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Is this bug related to Nuxt or Vue?

Nuxt and Vue

Package

v4.x

Version

v4.2.1

Reproduction

Open a DropdownMenu component page in the playground and specify the following options:

const toast = useToast()

const items = computed(() => [
  {
    label: 'Tool F',
    kbds: ['f'],
    onSelect() {
      toast.add({ description: 'Tool F selected!' })
    }
  },
  {
    label: 'Tool F-H',
    kbds: ['f', 'h'],
    onSelect() {
      toast.add({ description: 'Tool F-H selected!' })
    }
  },
  {
    label: 'Tool H',
    kbds: ['h'],
    onSelect() {
      toast.add({ description: 'Tool H selected!' })
    }
  }
])
defineShortcuts(extractShortcuts(items.value, '-'))

Then, try to trigger the F-H option from the keyboard. You will not be able to!

Screen.Recording.2025-12-11.110139.mp4

Description

At the moment, there is an issue with key sequences.

Given a dropdown menu items with F, F-H, and H shortcuts, if I press F or H keys separately, their actions are executed correctly. However, if I press F-H, Nuxt UI identifies them as two separate keys instead of a single key sequence.

It would be nice if Nuxt UI correctly handles such ambiguous key sequences.

Additional context

No response

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageAwaiting initial review and prioritizationv4#4488

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions