Repository navigation
fix(Selector, MultiSelector): a query change clears the highlight from the previous list - #8871
Conversation
…ion, never a disabled one
…light 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).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
There was a problem hiding this comment.
This fix needs an owner decision before it can be approved: component:Selector FR9 (highlight the first enabled match after each query change) and FR11 in the draft component:MultiSelector record (clear the highlight) are new rules that the current specs do not state, so an engineering owner records the decision by commenting /approve-spec <full head SHA> on this pull request, which the author may do as an engineering owner, or names a different rule. Separately, one regression and a few record details need fixing:
- Closing a searchable Selector after typing leaves the first option highlighted, so a list reopened by a click or Enter starts on it and Enter replaces the value, against FR8 (
Selector.tsx:1364-1368runs on the query reset at:1151); resetting the highlight from the typing handlers and adding a reopen test would fix it. - FR11 and the changeset say ArrowDown starts at the first match, but with
hasSelectAllorhasCreateit lands on Select all or the create row first. - Two of FR9's four listed cases (the disabled-only match and the shrinking list) already pass without the fix; arrowing down to Cherry and then typing
apreproduces the stale index. - The MultiSelector comment and test cite
component:SelectorFR9 for the clearing rule instead ofcomponent:MultiSelectorFR11, and FR11's table row is missing its review-state cell.
[Automated review]
…earch 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.
|
/approve-spec 9cb22b3 |
|
Posted by Cindy's agent on her behalf: the approval above covers this PR's own Selector FR9 consistency edit. It follows current Selector AR3 and the Typeahead first-match precedent: each query change highlights the first enabled filtered option. The FR8 opening-highlight row comes from the base PR and needs that PR's own approval. |
There was a problem hiding this comment.
This looks ready to approve: the new Selector FR9 and MultiSelector FR11 highlight rules carry an engineering owner's approval for this exact head, the reopen issue from the earlier revision is fixed, and the new tests fail before the change and pass after it. It should land after #8868, whose FR8 opening rule needs that pull request's own approval, and then be retargeted to main. One optional cleanup: the test named "skips a disabled first match" only covers a disabled-only match, so nothing yet guards moving past a disabled first match to the next enabled one.
[Automated review]
# 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
… 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.
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| Selector | 99.8 kB (+22 B) · 17.4 kB CSS (0) | — | ✗ · ✓ · ✓ |
| SelectorOption | 20.9 kB (0) · 6.1 kB CSS (0) | — | ✗ · ✓ · ✓ |
| MultiSelector · Storybook | 94.9 kB (+48 B) · 16.8 kB CSS (0) | 2,701 (+6) | ✓ · ✓ · ✓ |
3 more components
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| Pagination | 109.9 kB (+29 B) · 17.8 kB CSS (0) | — | — · — · — |
| richtext/RichTextEditorToolbar | 278.0 kB (+22 B) · 454 B CSS (0) | — | — · — · — |
| PowerSearch | 286.6 kB (+21 B) · 24.1 kB CSS (0) | — | — · — · — |
Visual changes: 4 snapshots in 1 component
A change is a question for the reviewer, not a failure.
Package size: @astryxdesign/core 7.19 MB packed (+591 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
…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.
|
/approve-spec 0d359f4 |
There was a problem hiding this comment.
Changes requested: the fix itself behaves as the new component:Selector FR9 and component:MultiSelector FR16 describe, but the description and two tests still need to catch up with the switch to clearing the highlight.
- The description's User impact lists "typing with nothing highlighted left Enter doing nothing" as a problem this change keeps by design, and its Evidence section describes first-match tests that no longer exist (Apple highlighted after
ap, Enter picking Cherry, a changed grouped-filter case, every Selector case failing onmain), so please rewrite both to match this head. - Both "clears a highlight left from before the query" cases arrow to index 3 before typing
b, so the old index is already past the two-row list and the Selector case passes onmain; press ArrowDown twice (Apricot) beforeband assert thataria-activedescendantis null, so a highlight kept inside the list (Blueberry, whichmainpicks on Enter) fails as the FR9 and FR16 verification rows say.
Smaller, non-blocking: the MultiSelector comment still says Selector moves to the first match, the Selector comment could keep only its reason, the avo case name promises a disabled-skip case it does not cover, and FR9's "does what it does today" could state the behavior.
[Automated review]
…ide 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.
|
/approve-spec 0dda469 |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet, because the pull request is still a draft; marking it ready for review starts the run.
Typing in a searchable Selector or MultiSelector now clears the highlight left from the previous list, as the newly approved component:Selector FR9 and component:MultiSelector FR16 describe. The in-list and past-the-end cases fail on main and pass here, and the earlier requests on the description and the tests are addressed.
Non-blocking: the two new source comments could drop "Adjusted during render rather than in an effect." (and MultiSelector's "so it is cleared"), which restate the code below them; suggestions are inline.
[Automated review]
| // A new query is a new list: the old highlight's index would name another | ||
| // option, or one past the end. Adjusted during render rather than in an | ||
| // effect. |
There was a problem hiding this comment.
Non-blocking (INV29): "Adjusted during render rather than in an effect." restates where the code below runs and gives no reason. Suggested: A new query is a new list. The old index would name another option, or one past the end.
| // A new query is a new list: the old highlight's index would name another | ||
| // row, or one past the end, so it is cleared. With no row highlighted, Left | ||
| // and Right stay the search field's caret keys. Adjusted during render | ||
| // rather than in an effect. |
There was a problem hiding this comment.
Non-blocking (INV29): "so it is cleared" restates setHighlightedIndex(-1) in the passive, and "Adjusted during render rather than in an effect." restates where the code runs. Suggested: A new query is a new list. The old index would name another row, or one past the end. With no row highlighted, Left and Right stay the search field's caret keys.












Fixes #8833. Builds on #8868 (merged; the opening highlight,
component:SelectorFR8).User impact
In a searchable
SelectororMultiSelector, a keyboard user who arrows down a few rows and then types a filter got a highlight left over from the old list. It named a different option of the filtered list, or one past its end, so Enter picked an option they never moved to, or nothing while no option looked highlighted.Problem and solution fit
component:SelectorFR8 doesn't allow for a search list opened by typing. In MultiSelector, a highlighted row would also take Left and Right into its action cell (component:MultiSelectorFR10), and Enter with nothing highlighted creates the typed label (FR9).Current specification
component:Selector: the searching state is "Visible options, keyboard navigation, and announced result count use one filter". APG combobox:aria-activedescendantmust reference a rendered element. New FR9: "In a search list, each change to the query clears the highlight, soaria-activedescendantnever names an option of the previous list; ArrowDown then starts at the first enabled option, and Enter with nothing highlighted selects nothing."component:MultiSelector: new FR16 records the clearing rule and how it relates to FR9 and FR10, with its verification row.Evidence
Selector.searchHighlight.test.tsx, 5 cases. 3 fail onmain:b.mainkeeps index 1 and highlights Blueberry, which Enter picks; here nothing is highlighted, Enter selects nothing, and ArrowDown lands on Banana.ap.mainkeeps an index past the two-row list; here nothing is highlighted, and ArrowDown lands on Apple.b.mainticks Blueberry on Enter; here Enter ticks nothing, and ArrowDown starts at Banana.check:knowledgeand the comment-provenance baseline pass.Writing rubric results