Skip to content

palette-react: publish aria-activedescendant for the initial highlight (#68) - #72

Merged
thorwhalen merged 2 commits into
mainfrom
palette-activedescendant-68
Oct 13, 2026
Merged

thorwhalen merged 2 commits into
mainfrom
palette-activedescendant-68

Conversation

@thorwhalen

@thorwhalen thorwhalen commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Closes #68.

cmdk 1.1.1 sets aria-selected on the first option at mount but only publishes its id on the input when the highlight moves (selectedItemId is written only from setState('value')). It also overrides any aria-activedescendant prop, and a controlled value is applied without publishing, so neither of the issue's options works as written. use-active-descendant.ts mirrors the selected option's id onto the input (callback ref on the cmdk root + MutationObserver on aria-selected), following the root through list/picker/list remounts and clearing it when nothing matches.

Tests: the loose assertion is tightened; new ones for filtering (incl. no match) and returning from the picker chain. Mutation-checked (without the ref, 3 tests fail). Package suite 40/40, tsc clean. Skill note and changeset updated.

Adversarial review (fresh Opus): fix-then-merge. Confirmed: the enum picker step (its own cmdk root) still had the bug — fixed with the same hook and a test (mutation-checked). Verified holding: no observer loop, no stale ids across mount/arrows/filter/no-match/hover/unregister/list-picker round trip, StrictMode, SSR; the claim that cmdk cannot publish it via controlled value is true. Suspicion not run: React 18 (only 19 installed). Cosmetic: cmdk leaves aria-activedescendant unset on the listbox element.

🤖 Generated with Claude Code

thorwhalen and others added 2 commits October 13, 2026 12:24
…ghted option (#68)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…oo (review of #68)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@thorwhalen
thorwhalen merged commit 934d8db into main Oct 13, 2026
2 checks passed
@thorwhalen
thorwhalen deleted the palette-activedescendant-68 branch October 13, 2026 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

palette-react: aria-activedescendant is not published for the initial highlighted option (cmdk 1.1.1)

1 participant