Repository navigation
[combobox] Keep ArrowLeft/ArrowRight on the input caret in grid mode - #4948
Merged
atomiks merged 5 commits intoJun 11, 2026
Merged
Conversation
In grid mode the navigation hook treats ArrowLeft/ArrowRight as horizontal grid movement, even before any item is highlighted. When focus is in the input that hijacks the user's caret editing. Wrap the list-navigation reference so those keys fall through to the input's native handler while no item is highlighted. Once an item is highlighted (via ArrowDown, autoHighlight, or earlier grid navigation) the existing behavior is preserved. Fixes mui#4947
commit: |
Bundle size
PerformanceTotal duration: 1,183.93 ms +56.78 ms(+5.0%) | Renders: 50 (+0) | Paint: 1,779.18 ms +75.63 ms(+4.4%)
11 tests within noise — details Check out the code infra dashboard for more information about this PR. |
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
atomiks
reviewed
Jun 11, 2026
Comment on lines
+1099
to
+1100
| store.state.activeIndex == null && | ||
| (event.key === 'ArrowLeft' || event.key === 'ArrowRight') |
Contributor
There was a problem hiding this comment.
This matches macOS' emoji picker, where ArrowLeft and ArrowRight do not work even if the text caret is at the end/boundary of the textbox (e.g. when it's empty). You need to press ArrowDown/ArrowUp. I guess that is fine.
atomiks
marked this pull request as ready for review
June 11, 2026 05:00
atomiks
requested review from
colmtuite,
flaviendelangle and
michaldudak
as code owners
June 11, 2026 05:00
atomiks
approved these changes
Jun 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4947.
Preview: https://deploy-preview-4948--base-ui.netlify.app/react/components/autocomplete#grid-layout
In grid mode
useListNavigationis configured withcols: 2andorientation: 'horizontal', so it reacts to ArrowLeft/ArrowRight on the reference element. The reference element is the input. When the input has focus and no item is highlighted yet, the user is still editing the query, and the arrow keys silently jump the highlight into the list (typically looping into the last cell) instead of moving the caret.The fix adds a guard props object to the input's
mergePropschain, placed right afterlistNavigation.reference: whileactiveIndex == nullin grid mode, ArrowLeft/ArrowRight callevent.preventBaseUIHandler()so the navigation handler is skipped and the input keeps its native caret behavior. Once an item is highlighted (via ArrowDown,autoHighlight, or earlier grid navigation) the event reaches the navigation hook as before and grid traversal continues unchanged. The guard readsstore.state.activeIndexnon-reactively at event time, so no extra reactive dependencies are introduced.This matches the ARIA APG "Editable Combobox with Grid Popup" pattern: Left/Right operate on the caret while no suggestion is focused, and move between cells once one is.
Tests
Added three cases under
prop: gridinComboboxRoot.test.tsx, two RED on master, one regression-preserve:moves the input caret on ArrowLeft when no item is highlighted in grid mode(RED on master)moves the input caret on ArrowRight when no item is highlighted in grid mode(RED on master)keeps grid navigation when autoHighlight surfaces an item before typing arrow keys(pins the only path where an item becomes highlighted without arrow keys)Horizontal navigation with a highlighted item is already covered by the existing
arrow keys navigate across rows and columns in grid modetest. Existing grid tests (arrow keys navigate across rows and columns in grid mode,mirrors horizontal grid navigation in RTL mode,supports uneven rows navigation) still pass, along with the rest of the Combobox suite and the Autocomplete suite.