Skip to content

fix(VCommandPalette): pass keyboard and click wiring to custom slots - #23260

Open
MatthewAry wants to merge 2 commits into
matthewary/fix-VCommandPalette-search-a11yfrom
matthewary/fix-VCommandPalette-slot-wiring
Open

MatthewAry wants to merge 2 commits into
matthewary/fix-VCommandPalette-search-a11yfrom
matthewary/fix-VCommandPalette-slot-wiring

Conversation

@MatthewAry

@MatthewAry MatthewAry commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Description

fixes #23259

Depends on #23258 and is based on its branch, so only the slot changes show here.

A custom input from the input slot had no keyboard navigation: the keydown handler (and now the combobox attributes) were only attached to the built-in VTextField. Clicking an item rendered through the item slot didn't run the command either.

Both slots now pass props to bind, like VSelect's item slot and VOverlay's activator slot:

  • input: { props } with role, aria-expanded, aria-controls, aria-autocomplete, aria-activedescendant and onKeydown. The built-in VTextField spreads the same object. A custom input is also focused when the palette opens.
  • item: { item, index, props }. props holds the same list item fields the default rendering uses (value, title, subtitle, icons, avatars) plus index and an onClick that runs the command, so other item fields like hotkey don't leak onto the DOM. onClick replaces the item's own handler instead of merging with it, because running the command already calls item.onClick(event, value).

props doesn't carry the search model: a VTextField needs modelValue, a native input needs value/onInput, and the built-in field already has its own v-model. The docs and slot descriptions say to connect a custom input to v-model:search instead.

Behavior change: item in the item, item.prepend, item.title and item.append slots is now the original item, matching the declared slot type. Before, it was the internal list props, where value was the filtered index.

Adds slot-input and slot-item docs examples.

Markup:

<template>
  <v-app theme="dark">
    <v-container max-width="600">
      <div class="d-flex ga-4 mb-4">
        <v-btn text="Custom input" @click="inputOpen = true" />
        <v-btn text="Custom item" @click="itemOpen = true" />
      </div>

      <code>click:item → {{ last || 'none' }}</code>

      <v-command-palette
        v-model="inputOpen"
        v-model:search="search"
        :items="items"
        @click:item="last = $event.title"
      >
        <template #input="{ props }">
          <input v-model="search" v-bind="props" class="pa-4 w-100" placeholder="Search">
        </template>
      </v-command-palette>

      <v-command-palette
        v-model="itemOpen"
        :items="items"
        @click:item="last = $event.title"
      >
        <template #item="{ props }">
          <v-list-item v-bind="props" />
        </template>
      </v-command-palette>
    </v-container>
  </v-app>
</template>

<script setup>
  import { shallowRef } from 'vue'

  const inputOpen = shallowRef(false)
  const itemOpen = shallowRef(false)
  const search = shallowRef('')
  const last = shallowRef('')

  const items = [
    { title: 'New file', value: 'new-file' },
    { title: 'Open file', value: 'open-file' },
    { title: 'Sign out', value: 'sign-out' },
  ]
</script>

🤖 Generated with Claude Code

The `input` slot now receives `props` with the combobox attributes and
keyboard handler, and the `item` slot receives `props` whose click runs
the command.

fixes #23259

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MatthewAry MatthewAry added T: bug Functionality that does not work as intended/expected C: VCommandPalette a11y Accessibility issue labels Oct 9, 2026
@MatthewAry MatthewAry added this to the v4.3.0 milestone Oct 9, 2026
@MatthewAry
MatthewAry requested a review from J-Sek October 9, 2026 22:07
@MatthewAry
MatthewAry marked this pull request as ready for review October 9, 2026 22:07
- item slot `props` only carries list item props, `item` is the original item
- focus a custom input when the palette opens
- document `v-model:search` for custom inputs, add input and item slot examples

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

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

Labels

a11y Accessibility issue C: VCommandPalette T: bug Functionality that does not work as intended/expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant