Repository navigation
fix(Selector): a row that scrolls under a still mouse does not take the keyboard's highlight - #9671
Conversation
…he keyboard's highlight End, Home, PageDown and type-to-select scroll the open list; the rows move under a resting mouse and the browser reports the row now under it as entered, which took the highlight (End landed on Team 116 of 120 in real Chrome). module:DropdownMenu/useMenuPress FR2 moves the highlight for a mouse that moves. Selector now notes, while open, whether the pointer moved (by screen coordinates) since the last key, a press counting as movement, and a row entered with no movement since a key keeps its hands off the highlight. Selector only; the shared hover hook is unchanged. Adds the Core/Selector Long list story (120 options). Test: after End under a still mouse, an entered row leaves the highlight on the last row; a moved mouse takes it (fails before).
Resolves the Selector.test.tsx conflict with the touch-action perf change: both new tests are kept.
…ove and the field's key handlers The first version added document keydown, pointerdown and pointermove listeners, which is modality tracking that interactionModality owns (architecture:react-component-runtime INV16). The field already handles every key that moves the highlight (the trigger, the search input and the sheet's listbox), so those handlers mark a key, and the listbox's own onPointerMove clears the mark when the pointer moves by screen coordinates. Chrome reports entering a row before the move that reaches it, so the move also gives the row under the pointer the highlight. Real Chrome (Long list story): End, Home and PageUp keep the keyboard's row under a resting mouse, including a list that opened by keyboard under a mouse that never moved over it; a 40 px move highlights the row under the pointer (Team 6), which the first version missed.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| Pagination | 86.5 kB (+312 B) · 16.0 kB CSS (0) | — | — · — · — |
| lab/MobilePowerSearch | 214.0 kB (+292 B) · 1.2 kB CSS (0) | — | — · — · — |
| lab/CommentThread | 227.4 kB (+290 B) · 2.4 kB CSS (0) | — | — · — · — |
34 more components
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| PowerSearch · Storybook | 184.6 kB (+267 B) · 20.6 kB CSS (0) | 3,986 (0) | — · — · — |
| Tokenizer | 70.5 kB (+267 B) · 17.1 kB CSS (0) | — | — · — · — |
| MultiSelector · Storybook | 73.0 kB (+261 B) · 15.2 kB CSS (0) | 2,702 (−2) | — · — · — |
| DateTimeInput · Storybook | 158.8 kB (+260 B) · 17.0 kB CSS (0) | 3,640 (0) | — · — · — |
| ChatComposerInput | 56.4 kB (+255 B) · 10.4 kB CSS (0) | — | — · — · — |
| ChatComposerTokenElement | 56.4 kB (+255 B) · 10.4 kB CSS (0) | — | — · — · — |
| ChatComposer | 61.3 kB (+249 B) · 11.2 kB CSS (0) | — | — · — · — |
| lab/CommentComposer | 102.7 kB (+248 B) · 1.9 kB CSS (0) | — | — · — · — |
| Selector | 77.4 kB (+247 B) · 15.7 kB CSS (0) | — | — · — · — |
| Typeahead | 63.1 kB (+246 B) · 11.8 kB CSS (0) | — | — · — · — |
| BaseTypeahead | 55.4 kB (+244 B) · 10.2 kB CSS (0) | — | — · — · — |
| CommandPalette | 49.1 kB (+239 B) · 12.2 kB CSS (0) | — | — · — · — |
| lab/Comments | 232.7 kB (+236 B) · 2.5 kB CSS (0) | — | — · — · — |
| richtext/RichTextEditorToolbar | 222.4 kB (+236 B) · 454 B CSS (0) | — | — · — · — |
| ChatComposerDrawer | 17.5 kB (0) · 4.7 kB CSS (0) | — | — · — · — |
| ChatDictationButton | 46.0 kB (0) · 9.8 kB CSS (0) | — | — · — · — |
| ChatLayout | 48.5 kB (0) · 10.3 kB CSS (0) | — | — · — · — |
| ChatLayoutScrollButton | 45.8 kB (0) · 9.9 kB CSS (0) | — | — · — · — |
| ChatMessage | 16.7 kB (0) · 3.7 kB CSS (0) | — | — · — · — |
| ChatMessageBubble | 7.1 kB (0) · 3.7 kB CSS (0) | — | — · — · — |
| ChatMessageList | 22.8 kB (0) · 7.9 kB CSS (0) | — | — · — · — |
| ChatMessageMetadata | 19.6 kB (0) · 4.1 kB CSS (0) | — | — · — · — |
| ChatSendButton | 45.2 kB (0) · 9.5 kB CSS (0) | — | — · — · — |
| ChatSystemMessage | 6.8 kB (0) · 3.8 kB CSS (0) | — | — · — · — |
| ChatTokenizedText | 7.1 kB (0) · 4.0 kB CSS (0) | — | — · — · — |
| ChatToolCalls | 25.8 kB (0) · 9.3 kB CSS (0) | — | — · — · — |
| CommandPaletteEmpty | 6.2 kB (0) · 3.5 kB CSS (0) | — | — · — · — |
| CommandPaletteFooter | 17.0 kB (0) · 3.7 kB CSS (0) | — | — · — · — |
| CommandPaletteGroup | 3.5 kB (0) · 3.5 kB CSS (0) | — | — · — · — |
| CommandPaletteInput | 26.8 kB (0) · 8.5 kB CSS (0) | — | — · — · — |
| CommandPaletteItem | 10.0 kB (0) · 3.6 kB CSS (0) | — | — · — · — |
| CommandPaletteList | 16.0 kB (0) · 3.4 kB CSS (0) | — | — · — · — |
| SelectorOption | 16.5 kB (0) · 5.4 kB CSS (0) | — | — · — · — |
| TypeaheadItem | 6.3 kB (0) · 3.6 kB CSS (0) | — | — · — · — |
Package size: @astryxdesign/core 6.09 MB packed (+2.1 kB); no new dependencies.
Wide change (7 components): add ci:run-visual, ci:run-a11y or ci:run-rtl to run them.
Generated by PR Enrichment workflow | View full report
There was a problem hiding this comment.
Changes requested.
The fix works for Selector: in Chromium, End, Home, PageDown and type-to-select now keep the keyed row under a resting mouse, and a moving mouse still takes the highlight. One change is needed before approval:
- The still-mouse guard (
isKeyNavigatingRef,lastPointerRef,onRowPointerEnterandhandleListPointerMoveinSelector.tsx) duplicates a concern the shared combobox highlight owner already holds (useComboboxinSelector/hooks.tsanduseHighlightedOptionScroll), so MultiSelector keeps the bug (a 120-option MultiSelector still jumps to the row under a resting mouse after End) and CommandPalette and Typeahead hover through the same unguarded path; please move the guard into that shared owner so Selector makes one call and the local refs and handlers go away.
Non-blocking: the comment above the new refs opens with a 26-word sentence that carries two facts; a suggested rewrite is inline.
[Automated review]
| const isKeyNavigatingRef = useRef(false); | ||
| const lastPointerRef = useRef<{x: number; y: number} | null>(null); | ||
| const onRowPointerEnter = useCallback( | ||
| (item: SelectorOptionData, index: number) => { | ||
| if (!isKeyNavigatingRef.current) { | ||
| onItemMouseEnter(item, index); | ||
| } | ||
| }, | ||
| [onItemMouseEnter], | ||
| ); |
There was a problem hiding this comment.
Blocking: this still-mouse guard is Selector-local, but the combobox hover/keyboard split already has a shared owner: useCombobox (Selector/hooks.ts, the comment above its useHighlightedOptionScroll call) and useHighlightedOptionScroll, which MultiSelector, Typeahead and CommandPalette also go through. A 120-option MultiSelector still jumps to the row under a resting mouse after End. Please move the guard into the shared owner (for example, arm it when a keyboard highlight scrolls and return a list pointer-move handler that disarms it on a real move), so Selector makes one call and these refs and handlers go away.
| // A key that scrolls the list (End, PageDown, typeahead) moves rows under | ||
| // a still mouse, and the browser reports the row now under it as entered. | ||
| // That is not the person moving the mouse, so the row does not take the | ||
| // highlight until the pointer moves. |
There was a problem hiding this comment.
Non-blocking: the first sentence is 26 words and carries two facts. A shorter version that keeps the quirk and the reason:
| // A key that scrolls the list (End, PageDown, typeahead) moves rows under | |
| // a still mouse, and the browser reports the row now under it as entered. | |
| // That is not the person moving the mouse, so the row does not take the | |
| // highlight until the pointer moves. | |
| // A key that scrolls the list moves rows under a still mouse. The browser | |
| // then reports the row under the mouse as entered. That row takes the | |
| // highlight only after the pointer moves. |
…for the pointer to move Per review: the still-mouse guard belongs to the shared owner of the combobox hover/keyboard split, so every list that uses it gets the fix (Selector, MultiSelector, Typeahead, Tokenizer, CommandPalette, the DateTimeInput time list and the Chat trigger menu). A keyboard-driven highlight change anchors the highlight; a hover that comes while it is anchored waits. The first real pointer move (by screen coordinates) releases it and applies the waiting hover, because Chrome reports entering a row before the move that reaches it. The hover callback takes an optional onHighlight, so MultiSelector's cell choice applies with the deferred highlight. Selector's own refs and handlers are removed. Tests: a MultiSelector still-mouse case (fails before); the Selector case follows Chrome's event order. Hover tests that opened by keyboard or click and then hovered with no pointer movement now move the pointer, as a real hover does.
There was a problem hiding this comment.
Not ready to approve yet: moving the still-mouse guard into useHighlightedOptionScroll fixes Selector (in Chromium, End and Home now keep the keyed row under a resting mouse), but three fixes are needed and one owner decision is open.
- Selector's press model highlights through the shared hover callback, so a press held still after a key, or right after the list opens, no longer lights the pressed row (in Chromium, a mouse held on Team 116 after End shows Team 120 until the release picks Team 116, and a finger held on Team 7 shows Team 1); please let a
pointerdownrelease the hold and add a test for a press held still after End. - The changeset says Typeahead and Tokenizer had this bug, but their rows already highlight only on
mousemoveonmain(the existing "highlight under a resting pointer" test covers it), so please drop both from the changeset and from the description's list. - CommandPalette passes
isOpen: truetouseCombobox, so a closed palette now keeps a documentpointermovelistener for as long as it is mounted; please subscribe only while the palette is open or while a hold is armed.
The same hover rule now also ships for MultiSelector, CommandPalette, the DateTimeInput time list, the Chat trigger menu, Typeahead and Tokenizer, while only Selector's record adopts useMenuPress FR2 (Selector FR7). An engineering owner needs to identify or add the record that governs it for those components and record that decision on this pull request, for example with /approve-spec <full head SHA>; the author may do so as an engineering owner.
[Automated review]
| (index: number) => { | ||
| const highlightFromHover = useCallback<HighlightFromHover>( | ||
| (index, onHighlight) => { | ||
| if (isKeyAnchoredRef.current) { |
There was a problem hiding this comment.
Blocking: Selector's press model reaches this callback too (Selector.tsx useMenuPress onHighlight → onItemMouseEnter), so a press held still after a key or right after opening is parked here and the pressed row is not lit until the pointer moves. In Chromium, a mouse held on Team 116 after End shows Team 120 until the release picks Team 116, against useMenuPress FR2 and Selector FR7. Letting a pointerdown release the hold (for example in the same Effect's listener set) would fix it; a test for a press held still after End would pin it.
| '@astryxdesign/core': patch | ||
| --- | ||
|
|
||
| [fix] In an open Selector, MultiSelector, Typeahead, Tokenizer, CommandPalette, DateTimeInput time list or Chat trigger menu, a key that scrolls the list (End, Home, PageDown, type-to-select) keeps the highlight where the key put it, even when the mouse is resting over the list. Before, the row that scrolled under the still pointer took the highlight. A mouse that moves still takes it. |
There was a problem hiding this comment.
Blocking: Typeahead and Tokenizer did not have this bug on main. BaseTypeahead rows highlight on mousemove, not mouseenter ("Highlight follows pointer movement, not pointer presence"), and the existing "BaseTypeahead highlight under a resting pointer" test asserts it. Suggested: "In an open Selector, MultiSelector, CommandPalette, DateTimeInput time list or Chat trigger menu, …".
| highlightFromHover(waiting.index, waiting.onHighlight); | ||
| } | ||
| }; | ||
| document.addEventListener('pointermove', onPointerMove, { |
There was a problem hiding this comment.
Blocking: CommandPalette calls useCombobox with isOpen: true at all times, so this listener stays on the document for as long as a palette is mounted, open or closed, and it is re-added on every highlight change. A closed <CommandPalette isOpen={false}> now holds one capture pointermove listener; on main it holds none. Subscribing only while the palette is really open, or only while a hold is armed, would match the description.
Resolves useHighlightedOptionScroll with main's stable hover callback: the keyboard anchor and the waiting hover live in refs, so the callback still reads no render state. The hook test moves the pointer before a hover, as a real hover does, and a new case checks that a hover after a keyboard move waits for the pointer and then applies with onHighlight. Selector.test.tsx keeps both new cases.
There was a problem hiding this comment.
Not ready to approve yet: the shared useHighlightedOptionScroll hold fixes Selector (in Chromium, End and Home keep the keyed row under a resting mouse), but three fixes are still needed after the merge, and one owner decision is open.
- Selector's press model highlights through the shared hover callback, so a press held still after a key, or a finger held right after the list opens, does not light the pressed row (in Chromium, a mouse held on Team 116 after End shows Team 120 until the release picks Team 116); please let a
pointerdownrelease the hold and add a test for a press held still after End. - The changeset says Typeahead and Tokenizer had this bug, but their rows already highlight only on
mousemoveonmain(the existing "highlight under a resting pointer" test covers it), so please drop both from the changeset and from the description's list. - CommandPalette passes
isOpen: truetouseCombobox, so a closed palette keeps a documentpointermovelistener for as long as it is mounted; please subscribe only while the palette is open or while a hold is armed.
The same hover rule now also ships for MultiSelector, CommandPalette, the DateTimeInput time list and the Chat trigger menu, while only Selector's record adopts useMenuPress FR2 (through Selector FR7). An engineering owner needs to identify or add the record that governs it for those components and record that decision on this pull request, for example by commenting /approve-spec <full head SHA>; the author may do so as an engineering owner.
[Automated review]
| if (isKeyAnchoredRef.current) { | ||
| waitingHoverRef.current = {index, onHighlight}; | ||
| return; | ||
| } |
There was a problem hiding this comment.
Blocking: Selector's press model reaches this callback too (Selector.tsx useMenuPress onHighlight → onItemMouseEnter), so a press held still after a key, or a finger held right after the list opens, is parked here and the pressed row is not lit until the pointer moves. In Chromium, a mouse held on Team 116 after End keeps Team 120 lit; the release still picks Team 116. useMenuPress FR2 and Selector FR7 require the held row to be lit (spec:AST-094 FR27 for a finger). Letting a pointerdown release the hold, as a real move does, would fix it; please add a test for a press held still after End.
| '@astryxdesign/core': patch | ||
| --- | ||
|
|
||
| [fix] In an open Selector, MultiSelector, Typeahead, Tokenizer, CommandPalette, DateTimeInput time list or Chat trigger menu, a key that scrolls the list (End, Home, PageDown, type-to-select) keeps the highlight where the key put it, even when the mouse is resting over the list. Before, the row that scrolled under the still pointer took the highlight. A mouse that moves still takes it. |
There was a problem hiding this comment.
Blocking: Typeahead and Tokenizer did not have this bug on main. BaseTypeahead rows highlight on mousemove, not mouseenter ("Highlight follows pointer movement, not pointer presence"), and the existing "BaseTypeahead highlight under a resting pointer" test asserts that a resting pointer keeps the keyboard highlight; Tokenizer composes BaseTypeahead. Suggested: "In an open Selector, MultiSelector, CommandPalette, DateTimeInput time list or Chat trigger menu, …".
| useEffect(() => { | ||
| if (!isOpen) { | ||
| return undefined; | ||
| } |
There was a problem hiding this comment.
Blocking: CommandPalette calls useCombobox with isOpen: true at all times (CommandPalette.tsx 400), so this listener stays on the document for as long as a palette is mounted, open or closed. A closed <CommandPalette isOpen={false}> holds one capture pointermove listener here and none on main. Passing the palette's real open state, or installing the listener only while a hold is armed, would keep it to the open list.
…s listeners live only while it does Per review: - A press releases the hold at once, as a real move does, so a press held still after a key lights the pressed row (useMenuPress FR2, Selector FR7). Test: a press held still after End (fails before). - The hold adds its document pointermove and pointerdown listeners when a keyboard move starts it and removes them on release, close or unmount. A list that is not shown has no option to scroll and starts no hold, so a closed CommandPalette (which reports itself open to useCombobox) adds no listener. Test: a closed palette adds no pointermove listener (fails before). - The changeset drops Typeahead and Tokenizer: their rows already follow mousemove only. - PowerSearch's field-menu hover test moves the pointer before its mousemove, as a real move does.
|
/approve-spec 80c84ba |
There was a problem hiding this comment.
Changes requested: one fix is left. The shared hold now keeps the keyed row under a resting mouse (in Chromium, End and Home keep Team 120 and Team 1 in a 120-option Selector) and a press held still lights the pressed row; the three earlier findings are resolved.
- The hold in
useHighlightedOptionScrollsurvives a highlight cleared to -1 (the scroll Effect returns early at line 164 and has no cleanup), so an inlineCommandPalettewith avalueno longer highlights it again after ArrowDown and a cleared query, leaving no active option until the pointer moves; please end the hold when the highlight is cleared (or returnendHoldas the Effect's cleanup), add an Effect note, and add a test for that sequence.
Non-blocking: the comment on holdRef (line 70) could become a clearer name, such as removeHoldListenersRef.
[Automated review]
| endHold(); | ||
| return; | ||
| } | ||
| if (isFromHover || highlightedIndex < 0) { |
There was a problem hiding this comment.
Blocking: when the highlight is cleared (highlightedIndex < 0), this returns without ending a hold an earlier key started. CommandPalette clears the highlight on every search, and an inline preview with a value highlights it again through the hover path, which the surviving hold now parks: after ArrowDown, typing and clearing the query, no option is active until the pointer moves (Chromium and jsdom; main makes the value active again). Ending the hold here (endHold() before return), or returning endHold as this Effect's cleanup, fixes it; a note naming what this Effect synchronizes would meet the Effect-note rule too.
| // Present while a keyboard move holds the highlight; removes the hold's | ||
| // document listeners. |
There was a problem hiding this comment.
Non-blocking: a name can carry the second half of this comment, for example removeHoldListenersRef, leaving // Set only while a keyboard move holds the highlight.
Per review: a hold a key started survived a highlight cleared to -1, so an inline CommandPalette that highlights its value by hover after a new search left no active option until the pointer moved. A cleared highlight, a closed list, or a list that is not shown now ends the hold. The scroll Effect carries its note; the hold's ref is named for what it holds. Tests: a hook case (a cleared highlight lets the next hover apply at once; fails before) and an inline CommandPalette sequence.
|
/approve-spec dfd324a |
There was a problem hiding this comment.
Looks good to approve. A key that scrolls the list now keeps its row under a resting mouse in Selector, MultiSelector, CommandPalette, the DateTimeInput time list and the Chat trigger menu, and a cleared highlight ends the hold, so an inline CommandPalette makes its value active again after a new query.
One optional follow-up:
- The new inline
CommandPalettetest renders a two-row source withvalue="settings", so ArrowDown stays on Settings, no hold starts, and the test also passes against the previous revision; starting fromvalue="home"(or a third row) would make it guard the regression it names.
[Automated review]
| isInline | ||
| onOpenChange={() => {}} | ||
| searchSource={simpleSource} | ||
| value="settings" |
There was a problem hiding this comment.
Non-blocking: with simpleSource (Home, Settings) and this value, the ArrowDown below starts on the last row, so the highlight stays on Settings and no hold starts. The test also passes against the previous revision's hook. value="home" (or a third row) lets ArrowDown move the highlight, so the test guards the cleared-query case it names.
User impact
A keyboard user no longer loses their place in a list when the mouse happens to rest over it. This covers Selector, MultiSelector, CommandPalette, the DateTimeInput time list and the Chat trigger menu. Typeahead and Tokenizer already followed only pointer movement.
Spec
module:DropdownMenu/useMenuPressFR2 says that "A mouse moving with no button down moves the highlight." A still mouse isn't moving, so the record already decides this.component:SelectorFR7 applies FR2 to the listbox. No record change.For MultiSelector, CommandPalette, the DateTimeInput time list and the Chat trigger menu, the governing rule is
module:DropdownMenu/useMenuPressFR2 plus each list's own existing "the pointer moves the highlight" behavior. A pointer that hasn't moved changing the highlight is a defect against those rules.Changes
useHighlightedOptionScroll: this is the shared owner of the combobox hover/keyboard split.onHighlight, so MultiSelector's cell choice applies with the deferred highlight.Selector.tsx: no local guard. Rows call the shared hover callback as before.Core/Selector"Long list" (120 options).[fix]patch.Evidence
Real Chrome (Chromium 154, 1024×768, CDP mouse input), Selector "Long list", with the mouse resting over the list. The highlighted row is the one
aria-activedescendantnames.A list opened by keyboard under a mouse that never moved over it keeps the keyboard's row through End and PageUp: Team 120, then Team 1.