Repository navigation
fix(Tokenizer): a pick from the focus list keeps focus and the list open - #11031
Conversation
With hasEntriesOnFocus, a pick from the settled focus list keeps the input focused and the list open while another loaded choice remains. The next choice becomes active, or the one before it after the last. The list keeps the rows the commit filtered, so it does not ask the source again. It closes when no choice remains, at maxEntries, when the field becomes disabled, on Escape, on Tab and on a press elsewhere. Narrows the consecutive-selection work by fullstackhacker. Co-authored-by: Mush Kapadia <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
|
/approve-spec fe0af20 |
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| PowerSearch · Storybook | 292.2 kB (+334 B) · 24.2 kB CSS (0) | 7,141 (0) | ✓ · ✓ · ✓ |
| Tokenizer · Storybook | 94.0 kB (+323 B) · 18.8 kB CSS (0) | 2,340 (0) | ✓ · ✓ · ✓ |
| Typeahead | 82.1 kB (+291 B) · 12.4 kB CSS (0) | — | ✓ · ✓ · ✓ |
2 more components
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| BaseTypeahead | 73.3 kB (+270 B) · 10.9 kB CSS (0) | — | ✓ · ✓ · ✓ |
| TypeaheadItem | 6.6 kB (0) · 3.6 kB CSS (0) | — | ✓ · ✓ · ✓ |
Package size: @astryxdesign/core 7.29 MB packed (+2.5 kB); no new dependencies.
API changes: none in this pull request
Committed API report behind this build: cli 36 rows, core 36 rows; run pnpm api:report.
Touched components checked; add ci:run-visual or ci:run-rtl to run the full suites.
Accessibility: 2 violation(s)
Accessibility Audit
Status: 2 accessibility violation(s) found — 2 serious.
PowerSearch - 1 issue(s)
- 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
- Rule:
color-contrast· Affects 2/37 stories · Learn more - WCAG: 1.4.3 (Level AA)
- Rule:
Tokenizer - 1 issue(s)
- 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
- Rule:
color-contrast· Affects 2/31 stories · Learn more - WCAG: 1.4.3 (Level AA)
- Rule:
Generated by PR Enrichment workflow | View full report
There was a problem hiding this comment.
Requesting changes. The first pick from the hasEntriesOnFocus list now keeps focus and the list open, as the Tokenizer record's FR14 asks, but the run of picks stops there, and the new Chromium test fails in CI.
- The second pick closes the kept list: each commit rebuilds Tokenizer's filtered source, which bumps
searchGenRef, so theresultsGenRef.current === searchGenRef.currentguard inhandleSelectfails and the pick takes the closing path (FR14, DEC-2). - After a pointer pick, a press elsewhere on the page closes the list but returns focus to the combobox, because the option press moved focus into the layer and
useFocusTraprestores it; the new test atTokenizerFocusListPick.a11y.chromium.spec.ts:97fails on this in the Component accessibility contracts job. - In PowerSearch, picking an
empty-valued field from the focus list now adds the filter and leaves the field list open with that field still listed, a desktop behavior change that needs an owner decision (or a touch-only gate), or the list could stay open only when the picked id is committed. - After a pick the caller does not commit, the kept-pick mark is never cleared, because its cleanup sits in an effect keyed to a committed-choices key that did not change, so the next committed change skips its reload and can leave empty-query rows under typed text.
- The changeset, the
hasEntriesOnFocusdocs and the FR14/FR15 "implemented and verified" status claim consecutive picks that the head does not deliver and no test exercises.
Please add tests that make two or more picks in a row, by pointer and by keyboard, in the unit suite and in the Chromium spec.
[Automated review]
… its focus The commit replaces the filtered source, so the kept rows are marked current and the next pick keeps the list too. The list stays open only when the picked id is committed; otherwise it closes as before. A press on an option keeps DOM focus on the input, so the popup does not return focus to it when a press elsewhere closes the list.
|
/approve-spec ed2a359 |
There was a problem hiding this comment.
Requesting changes. Consecutive picks from the hasEntriesOnFocus list now keep focus and the list open, and the earlier blocking findings are fixed; two defects remain.
- Miss:
BaseTypeahead.tsx:1110listshideList, which changes on every render, in the disabled effect's dependencies, so each re-render of a disabled field bumps the search generation and calls the caller'ssearchSource.cancel()again (five extra calls over five parent re-renders; none on main). - A caller that commits the pick in a transition or after a tick gets the token but a closed list, because the effect at
BaseTypeahead.tsx:1483-1492treats an unchanged committed value in the first render after the pick as a rejection, while FR14 and the changeset say a committed pick keeps the list open.
Keeping [isDisabled] and reading the latest hideList through a ref fixes the first; letting the caller's next committed change decide, with a transition-commit test, or keeping FR14 pending with a named gap, fixes the second. The Component accessibility contracts job, and the test gate with it, failed on a Table virtualization timing budget that this change does not load, so it needs a re-run.
[Automated review]
| * threshold. An empty query is not "below the minimum" — it is the | ||
| * untouched state, and `hasEntriesOnFocus` owns what happens there. | ||
| */ | ||
| function preventOptionFocus(event: React.MouseEvent) { |
There was a problem hiding this comment.
Non-blocking: this function sits between isBelowMinQueryLength's JSDoc (:572-576) and that function, so the doc now describes preventOptionFocus. Move it above the JSDoc block.
| // A pick from the settled focus list of a field with committed choices | ||
| // keeps the input focused and the list open while another loaded choice | ||
| // remains. The next choice in the shown order becomes active, or the | ||
| // one before it when the pick was last. The list keeps its rows, so a | ||
| // press elsewhere or Tab still closes it as usual. |
There was a problem hiding this comment.
Non-blocking (INV29): the first sentence has 26 words and the second restates the nextIndex arithmetic. Suggested: "A Tokenizer pick from the settled focus list keeps the list open while a choice remains. The rows stay, so a press elsewhere or Tab still closes the list."
| // A pick from a list that can stay open keeps DOM focus on the input. A | ||
| // press on an option then does not move focus into the popup, so the | ||
| // popup does not return focus to the input when a later press elsewhere | ||
| // closes it. |
There was a problem hiding this comment.
Non-blocking (INV29): the second sentence has 30 words. Suggested: "A press on an option keeps focus in the input. A later press elsewhere then keeps its own focus."
…e cancels once A pick from a kept list no longer closes it when the first render after the pick has no commit: the caller's next committed change decides, so a commit in a transition keeps the list too. Typing, a close, or a pick that closes the list clears the pending picks. The disable effect reads hideList through a ref, so a disabled field's re-renders no longer cancel the source again.
|
/approve-spec c0c1291 |
There was a problem hiding this comment.
Requesting changes. Picks from the hasEntriesOnFocus list now keep focus and the list open, including commits in a transition, and both blocking findings from the last review are fixed. One blocking finding remains:
- Miss: in PowerSearch, picking a field that opens the filter editor (Status in the Default story) and then choosing its value now reopens the field list under the field, where
mainkeeps it closed; when a kept list closes with a pick still pending, clear its rows as the pick-then-close path does and add a PowerSearch test for it, or get an owner decision for the reopen.
Non-blocking: the new comment at BaseTypeahead.tsx:959-961 has a 30-word sentence (INV29).
[Automated review]
When a kept focus list closes while a pick is still pending (a PowerSearch field that opens its editor, say), its rows drop as after a pick that closes the list, so focus returning to the input does not show them again.
|
/approve-spec 498c9af |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet, and it runs once the pull request is marked ready for review.
Picks from the hasEntriesOnFocus list keep focus and the list open with the next choice active, and the last blocking finding is fixed: in PowerSearch, choosing a value in the filter editor now leaves the field list closed, as on main, and a new test covers it. The pull request's own Chromium spec passes on this head.
Non-blocking:
- Miss: the record's readiness row (
Tokenizer.spec.md:69) still says DEC-2's implementation and exact-head evidence are pending, while FR14 and FR15 now read "implemented and verified"; updating that sentence keeps the record consistent.
[Automated review]
| committedIds != null && | ||
| [...keptFocusListPicks].some(id => committedIds.has(id)); | ||
| if (!isPickCommitted || results.length === 0) { | ||
| // The close drops the rows, as after a pick that closes the list. |
There was a problem hiding this comment.
Non-blocking (INV29): this comment sits on the line that restores the pending set, but it does not say why the set comes back. handleLayerHide drops the rows only while a pick is pending. Suggested: "Restore the pending picks. The close then drops the rows, as after a pick that closes the list."
| // The ids picked from a kept focus list since the last committed change. | ||
| // The caller's next committed change decides what happens to the list. When | ||
| // it adds one of these ids, the list keeps the rows that the commit's render | ||
| // filtered. The source is not asked again. Otherwise the list closes, as |
There was a problem hiding this comment.
Non-blocking (INV29): "The source is not asked again" is passive. Suggested: "The reload does not ask the source again."
|
/approve-spec 8e2da31 |
There was a problem hiding this comment.
Requesting changes. Picks from the hasEntriesOnFocus list now keep focus and the list open with the next choice active, in jsdom and in real Chromium, and the record's readiness row now reads DEC-2 as implemented. One blocking issue remains:
- Miss: the kept-list check at
BaseTypeahead.tsx:1607keys on Tokenizer's committed-values context, which also reaches a field rendered inside a Tokenizermenuwithrole: 'dialog', so a single-selectTypeaheadwithhasEntriesOnFocusthere now keeps its list open after a pick wheremaincloses it, againstcomponent:TokenizerDEC-2 andcomponent:BaseTypeaheadFR1; resettingCommittedChoicesKeyContexttoundefinedaround the dialog menu's content, with a test for that case, fixes it.
The earlier non-blocking notes on preventOptionFocus placement and comment wording still stand. CI has not run on this draft head yet.
[Automated review]
…mitted values The menu content renders under an empty committed-choices context, so a single-select field inside a Tokenizer dialog menu keeps its own pick-then-close lifecycle.
|
/approve-spec 8fe52d7 |
There was a problem hiding this comment.
Approved pending a CI rerun: CI has finished, and its test gate fails only because Component accessibility contracts failed on a Table virtualization frame-time budget (TableVirtualization.release.a11y.chromium.spec.ts) whose fixture does not load the changed code. Rerun that job so the gate can pass.
Picks from the hasEntriesOnFocus list now keep focus and the list open with the next choice active, as Tokenizer's FR14, FR15 and AR5 require. The new tests fail on main and pass here, and the Chromium spec passes in CI.
- Optional: move
preventOptionFocusaboveisBelowMinQueryLength's JSDoc inBaseTypeahead.tsx, and list the "field becomes disabled" test with the regression guards in the description, since it fails onmain.
[Automated review]
|
/approve-spec 06639e3 |
There was a problem hiding this comment.
Approved pending CI: the required build, test and docsite-test suites are deferred for this push and run in the pre-merge re-run.
A pick from the hasEntriesOnFocus list keeps focus and the list open with the next choice active, as the Tokenizer record's FR14, FR15 and AR5 require. The new tests fail on main and pass here, and in Chromium the kept list and its closes on Escape, Tab and a press elsewhere behave as the record says. Merging main into the branch changes nothing in this pull request.
Optional follow-ups, none blocking:
- Newly live check: the FR14 and FR15 status cells and the readiness sentence now state build status ("implemented and verified", "current and implemented"); the record's writing rules ask for "Verified current behavior" style wording and an R7 line in the rubric results.
- The open comment-wording threads on
BaseTypeahead.tsxstill apply.
[Automated review]
| | FR13 | Tokenizer MUST exclude every choice whose `SearchableItem.id` is already present in its committed `value` from displayed bootstrap and search cohorts, including results that settle after the controlled value changes. A caller-rejected proposed value remains eligible because it was not committed. Distinct IDs remain eligible even when their labels match. | Approved Tokenizer multi-selection contract | Current contract; implementation and verification pending | | ||
| | FR14 | With `hasEntriesOnFocus` enabled, committing a choice from the current settled empty-query bootstrap cohort MUST keep the input focused and the popup open when another eligible loaded choice remains. The active option advances to the next remaining choice in displayed order; when the committed choice was last, the nearest preceding choice becomes active. `aria-activedescendant` MUST reference that rendered option. | Approved rapid multi-select lifecycle | Current contract; implementation and verification pending | | ||
| | FR15 | The retained popup MUST close and clear its active descendant when no eligible loaded choice remains, `maxEntries` is reached, the control becomes disabled, focus leaves, or the person dismisses it. Disabled Tokenizer remains non-interactive. Pending or stale source work MUST NOT reopen a terminal popup or expose stale choices; loading has no selectable placeholder and its busy state clears when work is cancelled or settles. | Approved terminal-state safety boundary | Current contract; implementation and verification pending | | ||
| | FR14 | With `hasEntriesOnFocus` enabled, committing a choice from the current settled empty-query bootstrap cohort MUST keep the input focused and the popup open when another eligible loaded choice remains. The active option advances to the next remaining choice in displayed order; when the committed choice was last, the nearest preceding choice becomes active. `aria-activedescendant` MUST reference that rendered option. | Approved rapid multi-select lifecycle | Current contract; implemented and verified | |
There was a problem hiding this comment.
Non-blocking (architecture:knowledge-contracts INV32, rubric R7, now on main): "Current contract; implemented and verified" here and in FR15, and "DEC-2 is current and implemented" in the readiness row, state what is built so far. "Verified current behavior", as FR16–FR28 read, and "DEC-2 is current" keep what the record requires. The description's Writing rubric results also need an R7 line.
There was a problem hiding this comment.
Requesting changes. Picks from the hasEntriesOnFocus list now keep focus and the list open by pointer and keyboard, and the Escape, Tab, press-elsewhere, exhaustion and maxEntries closes all hold; one timing gap remains.
- Miss: pressing Enter within the debounce after clearing typed text keeps the typed query's rows open as the focus list, and they come back on every reopen (in the With Entries On Focus story Bob Smith is missing and Frank Miller, Grace Lee and Henry Davis appear), because
keepsFocusList(BaseTypeahead.tsx:1609-1619) does not check the focus-list reload still waiting insearchTimeoutRef; addingsearchTimeoutRef.current == nullto the gate, with a test that types, clears and presses Enter within the debounce, restores the close thatmaindoes.
The earlier non-blocking notes on comment wording and the record's status cells still stand in their threads.
[Automated review]
…loses the list The kept-list gate now also requires no search waiting in searchTimeoutRef. Enter on typed results right after the text is cleared closes the list as on main, and a later open shows the focus list, not the typed rows.
|
/approve-spec f4cc68b |
There was a problem hiding this comment.
Approved. Picks from the hasEntriesOnFocus list keep focus and the list open with the next choice active, by pointer and keyboard, and the list still closes when no choice is left, at maxEntries, on disable, Escape, Tab and a press elsewhere; picks from typed results and PowerSearch's field list end as before. CI passes on this head, including the new Chromium spec.
The earlier non-blocking notes still stand in their threads: the comment wording at the pick and reload paths, preventOptionFocus sitting between isBelowMinQueryLength and its JSDoc, and the record's "implemented and verified" status cells.
User impact
A Tokenizer with
hasEntriesOnFocusshows a list of choices on focus. Today a pick from that list closes it, so someone adding several people or tags has to refocus or type before each pick.After this change, a pick from that list keeps the input focused and the list open while another choice remains. The next choice becomes active, so Enter or a click adds it at once. Keyboard, screen-reader and pointer users get the same flow: focus stays on the combobox,
aria-expandedstays true, andaria-activedescendantnames the next choice.This narrows #6360 to the part the Tokenizer record already requires. The engine refactor and the other changes in #6360 are not included.
Problem and solution fit
component:TokenizerFR14, FR15 and AR5 are current, and their status reads "implementation and verification pending".The fix lives in BaseTypeahead's pick path, and only for a field that supplies committed choices (Tokenizer). When a pick comes from the settled focus list, it keeps the rows and makes the next one active, or the one before it when the pick was last. The commit's existing in-render filter then drops the picked choice.
The caller's next committed change decides what happens to the list, whether it comes in the same event, in a transition or later:
A pick the caller does not commit stays eligible (FR13), and the list keeps it. Typing, a close, or a pick that closes the list clears the pending picks. A kept list that closes before a commit decides it drops its rows, as after a pick that closes the list. This covers a PowerSearch field that opens its value editor, so focus returning to the field does not reopen the field list.
A press on an option in such a list keeps DOM focus on the input. So a later press elsewhere on the page keeps its own focus; the popup does not return focus to the combobox.
Direct
BaseTypeaheadandTypeaheadkeep their pick-then-close behaviour, and so does a Tokenizer pick from typed search results.Expected behavior and authority
component:Tokenizer:maxEntries, when the field becomes disabled, when focus leaves, or on dismissal.aria-expandedstays true, andaria-activedescendantnames the next option.The record's FR14 and FR15 status changes to "implemented and verified", and its readiness row reads DEC-2 as implemented. The verification row names the new tests, and
verified_bylists the new Chromium spec.Smallest restoration
BaseTypeahead.tsx, with no public API or prop changes:Tokenizer.doc.mjs: thehasEntriesOnFocusdescription (English, Chinese, dense) says what a pick does.[fix]Changeset for@astryxdesign/core.Evidence
main: a pointer pick, a keyboard pick, a last-choice pick, and three or more picks in a row by pointer and by keyboard.main;main, where the list always closes, and keep passing with the kept list:maxEntries;main, becausemaincloses the list at the pick, before the test checks that it is open.bootstrapruns once across all picks.TokenizerFocusListPick.a11y.chromium.spec.tsagainst the "With Entries On Focus" story covers:Scope
Testing
vitest run packages/core/src/Tokenizer packages/core/src/Typeahead packages/core/src/PowerSearch: 1,013 passed at an earlier head; the Tokenizer and PowerSearch files: 187 passed at this head.tsc, eslint (no new findings),check:knowledge,check:changesetsand the comment-provenance baseline.Writing rubric results
Run over the
Tokenizer.spec.mdedits (two status cells, one verification cell, one readiness sentence, oneverified_byentry).(Posted by Cindy's agent on her behalf.)
Co-authored-by: fullstackhacker [email protected]