Skip to content

fix(Selector): a closed list opens on the selected option, never a disabled one - #8868

Merged
cixzhang merged 5 commits into
mainfrom
lane4/selector-closed-arrow-open-selected
Nov 9, 2026
Merged

cixzhang merged 5 commits into
mainfrom
lane4/selector-closed-arrow-open-selected

Conversation

@cixzhang

@cixzhang cixzhang commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Part of #8832 (its Selector half; the MultiSelector half stays open).

User impact

A keyboard user opening a closed Selector with the arrow keys can land on an option that can't be picked. ArrowDown highlights option 0 and ArrowUp the last option, disabled or not, so the list opens with a disabled option active and Enter does nothing. ArrowDown also ignores the current value: with "Hard" selected, ArrowDown then Enter changes the value to "Easy", while the same keys after a click keep "Hard".

After this change every way of opening a Selector lands on an option a person can pick: the selected one when there is one, otherwise the first (ArrowUp: last) enabled one.

Problem and solution fit

  • Why does it happen? useCombobox opens from closed with setHighlightedIndex(0) or selectableItems.length - 1, without checking disabled or the value. Click, Enter and Space use the selected index but fall back to 0, which can also be disabled.
  • Why does it harm the task? aria-activedescendant names an option that can't be chosen, and a habitual ArrowDown, Enter silently replaces the value.
  • Why does it matter? Once the list is open, the arrows, Home and End already skip disabled options; opening was the one path that didn't.

One helper (findOpeningIndex) now decides the opening highlight for every opening path.

Expected behavior and authority

  • component:Selector FR8 (approved by the specs owner):
    • opening highlights the selected option when it's enabled;
    • otherwise ArrowUp highlights the last enabled option, and any other way of opening the first enabled option;
    • nothing is highlighted when none is enabled;
    • a disabled option is never highlighted on opening;
    • a search list opened by a press, Enter or typing still highlights nothing.
  • WAI-ARIA APG listbox (focus goes to the selected option) and select-only combobox (Down Arrow opens without changing the selection).
  • MultiSelector and useMultiCombobox are unchanged. Extending the rule there is a separate owner question (which of several selected options to highlight, and the open list moves selected options to the top).

Smallest restoration

Evidence

  • Reproduction before the change: Selector.openHighlight.test.tsx, 8 cases, all failing on main. ArrowDown and ArrowUp open on "Archived" or "Retired" (both disabled) instead of "Hard" or the first or last enabled option; an all-disabled list still names an active option; ArrowDown then Enter on an all-enabled list picks "Easy" instead of keeping "Hard".
  • Result after the change: all 8 pass.
  • Representative unchanged path: the Selector, MultiSelector, useCombobox, CommandPalette and listbox/combobox binding suites (16 files, 580 tests). CommandPalette uses useCombobox always-open, so its opening path doesn't run.

Scope

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

  • vitest for Selector and MultiSelector (16 files, 580 tests); pnpm check:knowledge; the comment-provenance baseline check.

Writing rubric results

  • R1 narration: none. FR8 states the system in the present tense.
  • R2 research: none in the record.
  • R3 evidence: the FR8 basis cites the WAI-ARIA patterns and the test file.
  • R4 rejected alternatives: none.
  • R5 change references: none.
  • R6 open questions: none added.

@vercel

vercel Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 8, 2026 11:15pm UTC

Request Review

@astracat-bot

astracat-bot Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 8, 2026, 11:20 PM UTC

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval waits on an owner decision and five fixes. The Selector fix behaves as described and its FR8 record change is approved at this head, but the same opening rule also ships for MultiSelector and the public useMultiCombobox, and the MultiSelector record does not state it. An engineering owner needs to settle that rule in the MultiSelector record and record the decision by commenting /approve-spec <full head SHA> on the head that carries it, and the author may do so if they are an engineering owner. Because the fixes below need a new commit, FR8 needs that approval again on the new head.

  • With a value selected, MultiSelector now opens on a disabled option after ArrowDown, Enter or a click, because the opening index is taken before the open list moves selected options to the top.
  • The Changeset says opening "never highlights a disabled option" and that Selector "opens on the selected option with every key", which the MultiSelector case above and a search Selector opened by Enter, a press or typing contradict.
  • FR8 says opening highlights the selected option, but typing on a closed search Selector opens the list with nothing highlighted, so the exemption should name typing or leave it to the search behavior.
  • Line 35 of useCombobox.doc.mjs and the dense descriptions in both hook docs still say ArrowDown and ArrowUp open on the first and last option.
  • The Changeset needs to name the hooks' old first-or-last opening and the accessibility target the fix serves, as the release rules require for a patch that changes documented keyboard behavior.

[Automated review]

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 1c30c6f

@cixzhang

Copy link
Copy Markdown
Contributor Author

Posted by Cindy's agent on her behalf: the approval above covers a consistency edit to Selector FR8 (the opening highlight). Opening goes to the enabled selected option; otherwise ArrowUp goes to the last enabled option and any other opening to the first; a disabled option is never highlighted. This follows the WAI-ARIA listbox and select-only combobox patterns.

@cixzhang
cixzhang marked this pull request as draft October 31, 2026 18:08
@cixzhang cixzhang added the ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) label Nov 8, 2026
Main moved Selector.spec.md to docs/specs/components/Selector and
changed MultiSelector/hooks.ts. This merge takes main's MultiSelector
hooks and doc as they are, so MultiSelector keeps its current opening
highlight; that rule is a separate records question.

Also from review: FR8 names typing among the search openings that
highlight nothing; the changeset names the old first-or-last opening
and the listbox target; useCombobox's docs and dense lines describe
the selected-then-enabled opening; the keep-selected test uses an
all-enabled list, so it fails without the fix.
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 7353e71

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
Selector 99.6 kB (+36 B) · 17.4 kB CSS (0) — ✗ · ✓ · ✓
SelectorOption 20.9 kB (0) · 6.1 kB CSS (0) — ✗ · ✓ · ✓
richtext/RichTextEditorToolbar 277.8 kB (+51 B) · 454 B CSS (0) — — · — · —
3 more components
Component Size LoC Visual · A11y · RTL
Pagination 109.7 kB (+41 B) · 17.8 kB CSS (0) — — · — · —
PowerSearch 285.0 kB (+40 B) · 24.1 kB CSS (0) — — · — · —
CommandPalette 73.1 kB (+30 B) · 12.7 kB CSS (0) — — · — · —
Visual changes: 4 snapshots in 1 component

A change is a question for the reviewer, not a failure.

Component · story Before After Diff
Selector · Indicator Space Bottom Sheet Wide Start (neutral, dark) before frame after frame diff frame
Selector · Indicator Space Bottom Sheet Wide Start (neutral, light) before frame after frame diff frame
Selector · Indicator Space Bottom Sheet Narrow End RTL (neutral, dark) before frame after frame diff frame
Selector · Indicator Space Bottom Sheet Narrow End RTL (neutral, light) before frame after frame diff frame

Package size: @astryxdesign/core 7.17 MB packed (+292 B); no new dependencies.

API changes: none in this pull request

Committed API report behind this build: cli 29 rows, core 34 rows, theme-butter 1 row, theme-y2k 1 row; run pnpm api:report.

Touched components checked; add ci:run-visual or ci:run-rtl to run the full suites.


Generated by PR Enrichment workflow | View full report

@cixzhang

cixzhang commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 99e5202

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 8, 2026

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested for one fix to the pull request text; the code change itself is in good shape, component:Selector FR8 is approved at this head, and the new tests fail on main and pass here.

  • The title, the description and Fixes #8832 still describe a MultiSelector and useMultiCombobox fix that this head no longer makes (packages/core/src/MultiSelector/hooks.ts still opens on index 0 and the last index), so please retitle to fix(Selector): a closed list opens on the selected option, never a disabled one, reference #8832 without a closing keyword so its MultiSelector half stays open, and drop MultiSelector from the description (the test file has 8 Selector cases, all failing on main).

Editing the title and description creates no commit, so the FR8 approval stays valid. Optional: the options.value hook doc could keep the search-list exception, and a press or Space case would pin the remaining FR8 opening paths.

[Automated review]

Comment thread packages/core/src/Selector/hooks.ts Resolved
@cixzhang
cixzhang marked this pull request as ready for review November 8, 2026 22:39
@cixzhang
cixzhang marked this pull request as draft November 8, 2026 23:06
@cixzhang cixzhang changed the title fix(Selector, MultiSelector): a closed list opens on the selected option, never a disabled one fix(Selector): a closed list opens on the selected option, never a disabled one Nov 8, 2026
@cixzhang

cixzhang commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 7353e71

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending CI: CI has not run on this head yet because the pull request is still a draft; it runs once the pull request is marked ready for review.

component:Selector FR8 is approved at this head, the new Selector.openHighlight.test.tsx cases fail on main and pass here, and the title and description now cover only the Selector half of #8832, as requested earlier.

Optional, non-blocking:

  • The options.value hook doc could keep the search-list exception: a search list opened by a press or Enter highlights nothing.
  • A press or Space case would pin the two FR8 opening paths the tests do not cover yet.

[Automated review]

type: 'string',
description:
'The selected value. Without search, opening by a press, Enter or Space highlights it, or the first option when nothing is selected; ArrowDown and ArrowUp open on the first and last option.',
'The selected value. Opening the list highlights it when it is enabled; otherwise ArrowUp opens on the last enabled option and ArrowDown, a press, Enter or Space on the first. A disabled option is never highlighted on opening, and with no enabled option nothing is.',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: with hasSearch, a press or Enter opens with nothing highlighted, even when the selected option is enabled (FR8, and the options.hasSearch doc below). Keeping that exception here would make this entry true on its own, for example: "Opening the list highlights it when it is enabled, except that a search list opened by a press or Enter highlights nothing; otherwise ArrowUp opens on the last enabled option and ArrowDown, a press, Enter or Space on the first."

@cixzhang
cixzhang marked this pull request as ready for review November 8, 2026 23:52
github-actions Bot added a commit that referenced this pull request Nov 9, 2026
@cixzhang
cixzhang merged commit d69b6aa into main Nov 9, 2026
130 checks passed
cixzhang added a commit that referenced this pull request Nov 9, 2026
…m the previous list (#8871)

* fix(Selector, MultiSelector): a closed list opens on the selected option, never a disabled one

* docs(Selector): record the opening highlight (FR8); hook docs and changeset

* fix(Selector, MultiSelector): a query change no longer keeps the highlight from the previous list

With hasSearch, the highlight was an index into the filtered list that
survived query changes: after arrowing and typing it named another option,
or one past the end, so aria-activedescendant pointed at nothing rendered
and Enter picked an option the user never moved to, or nothing.

Selector (component:Selector FR9): each query change highlights the first
enabled match of the new list, as the library's Typeahead does. MultiSelector
(component:MultiSelector FR11): each query change clears the highlight,
because with a row highlighted Left and Right move into a row's action cell
instead of the caret (FR10), and Enter with nothing highlighted creates
(FR9); ArrowDown then starts at the first match. Both adjust during render
as the query changes.

Selector.searchHighlight.test.tsx; the Selector cases fail on main.
Stacked on #8868 (opening highlight, FR8).

* fix(Selector): a query reset on close is no new list, so a reopened search list highlights nothing

CodeBunny: closing a searchable Selector reset the query, and the FR9
render-time adjust then highlighted the first option, so a list reopened by
a press or Enter started on it and Enter replaced the value, against FR8.
The adjust now highlights the first enabled match only while the list is
open; a reset while closed clears the highlight.

Also: MultiSelector FR11 and the changeset say ArrowDown starts at Select
all or the create row when shown; the MultiSelector comment and test cite
MultiSelector FR11; FR11's table row gets its review-state cell; FR9's
verification row names the failing-before case (ArrowDown to Cherry, then
'ap'), now a test, and the reopen case.

* Merge remote-tracking branch 'refs/remotes/l4/main' into lane4/x8871

# Conflicts:
#	.changeset/selector-opens-on-selected.md
#	docs/specs/components/Selector/Selector.spec.md
#	packages/core/src/MultiSelector/MultiSelector.spec.md
#	packages/core/src/MultiSelector/MultiSelector.tsx
#	packages/core/src/MultiSelector/hooks.ts
#	packages/core/src/Selector/Selector.openHighlight.test.tsx
#	packages/core/src/Selector/Selector.tsx
#	packages/core/src/Selector/hooks.ts

* fix(Selector, MultiSelector): place the query reset after its inputs, and match main's trigger name

MultiSelector reads searchQuery and setHighlightedIndex, so its reset
sits after the combobox hook. A searchable Selector's trigger name now
carries the selected value, so the tests match its leading label.

* fix(Selector): a query change clears the highlight, as MultiSelector's does

Highlighting the first match on every query change would be automatic
selection, which FR8 does not allow for a search list opened by typing.
Selector now clears the highlight like MultiSelector: ArrowDown starts
at the first enabled match, and Enter with nothing highlighted does
what it did before. FR9, its verification row and the changeset say
so.

* test(Selector, MultiSelector): the clear cases keep the old index inside the new list

Arrowing to Apricot before typing b leaves an index inside the two-row
list, so main highlights Blueberry and these cases fail there. FR9
states that Enter with nothing highlighted selects nothing, and two
comments keep only their reasons.
@github-actions
github-actions Bot deleted the lane4/selector-closed-arrow-open-selected branch November 9, 2026 06:03

This branch was successfully deployed

1 active deployment
Preview — 7353e716 Deployed Nov 8, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant