Skip to content

fix(VCommandPalette): expose highlighted item to screen readers - #23258

Merged
J-Sek merged 7 commits into
devfrom
matthewary/fix-VCommandPalette-search-a11y
Oct 13, 2026
Merged

J-Sek merged 7 commits into
devfrom
matthewary/fix-VCommandPalette-search-a11y

Conversation

@MatthewAry

@MatthewAry MatthewAry commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Description

fixes #23257

The search input keeps DOM focus while arrow keys move the highlight, but aria-activedescendant was only set on the listbox, which never has focus. Screen readers announced nothing while moving through results, so Enter ran a command the user never heard.

The input now follows the editable combobox with list autocomplete pattern: role="combobox", aria-autocomplete="list", aria-expanded, aria-controls pointing at the results list, and aria-activedescendant pointing at the highlighted option. With no results, aria-expanded is false and aria-controls / aria-activedescendant are dropped.

Item ids come from VList's private useId(), so VList now exposes activeDescendant (the same value it already renders on its own aria-activedescendant).

The highlighted option also gets aria-selected="true" under navigationStrategy="track", as the pattern expects. activeDescendant never points at a subheader or divider, and the palette no longer falls back to index 0 when nothing is selectable (Enter used to run on a subheader).

Targeting dev because of the new exposed member. It's only there to make the fix possible, so a master patch is also defensible; maintainers' call.

Deferred:

Markup:

<template>
  <v-app theme="dark">
    <v-container max-width="600">
      <v-btn text="Open command palette" @click="open = true" />

      <v-command-palette v-model="open" :items="items" />
    </v-container>
  </v-app>
</template>

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

  const open = shallowRef(false)

  const items = [
    { type: 'subheader', title: 'File' },
    { title: 'New file', value: 'new-file', prependIcon: 'mdi-file-plus' },
    { title: 'Open file', value: 'open-file', prependIcon: 'mdi-folder-open' },
    { type: 'divider' },
    { type: 'subheader', title: 'Account' },
    { title: 'Sign out', value: 'sign-out', prependIcon: 'mdi-logout' },
  ]
</script>

🤖 Generated with Claude Code

MatthewAry and others added 2 commits October 9, 2026 10:52
The search input keeps focus while the highlight moves, but only the
listbox carried aria-activedescendant. The input is now a combobox that
points at the highlighted option and the results list.

VList exposes `activeDescendant` so the focused element can reference
the tracked item.

fixes #23257

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@MatthewAry
MatthewAry marked this pull request as ready for review October 9, 2026 18:22
@MatthewAry

Copy link
Copy Markdown
Contributor Author

@J-Sek I hope this PR does not strike you as slop, but I openly admit that it was all done with AI. If you find that irritating, please let me know. I will be more involved if needed.

@MatthewAry
MatthewAry requested a review from J-Sek October 9, 2026 18:25
- never reference subheaders or dividers as the active descendant
- mark the tracked option as selected
- keep aria-controls in sync when listProps sets an id
- document the combobox semantics and the item slot

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@MatthewAry MatthewAry added this to the v4.3.0 milestone Oct 9, 2026
@MatthewAry MatthewAry added T: bug Functionality that does not work as intended/expected C: VCommandPalette C: VList a11y Accessibility issue labels Oct 9, 2026
@J-Sek
J-Sek merged commit 3d79adb into dev Oct 13, 2026
15 checks passed
@J-Sek
J-Sek deleted the matthewary/fix-VCommandPalette-search-a11y branch October 13, 2026 21:04
@J-Sek

J-Sek commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

It's great that you are taking care of it. Hopefully we will start dogfooding it when the time comes to overhaul the docs.

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

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants