fix(combobox): scroll highlighted option into view (comboboxes-5)#3377
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR No new or modified components detected. Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
30 tasks
ejhammond
approved these changes
Jul 2, 2026
josephfarina
approved these changes
Jul 2, 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.
Part of the accessibility & keyboard-management program (#3343). Fixes
comboboxes-5.Problem
In
Selector,MultiSelector, andBaseTypeahead, the option list is a fixed-height (300pxmax-height) scroll container. When navigating options with the arrow keys, the highlighted option was never scrolled into view. Once keyboard navigation moved past the visible window (~8 items), the virtual cursor walked off-screen — the user could no longer see which option was highlighted, even thougharia-activedescendantcorrectly pointed at it.CommandPalettealready solves this inCommandPaletteItemvia auseEffectthat callsel.scrollIntoView({block: 'nearest'})whenever the item becomes highlighted. The three combobox surfaces were missing the equivalent behavior.Fix
Replicate the proven
CommandPalettepattern. Each component already tracks ahighlightedIndexand produces stable option element ids (getItemId(index)), so the smallest, least-invasive change is auseEffectkeyed onhighlightedIndexthat scrolls the highlighted option into view while the popup is open:{block: 'nearest'}to avoid jumpy scrolling (matchesCommandPalette).Applied to:
packages/core/src/Selector/Selector.tsxpackages/core/src/MultiSelector/MultiSelector.tsxpackages/core/src/Typeahead/BaseTypeahead.tsxTests
Added one keyboard-navigation test per component. Each spies on
Element.prototype.scrollIntoView, opens the dropdown, pressesArrowDowna few times, and assertsscrollIntoViewwas called with{block: 'nearest'}— mirroring the mocking approach used inCommandPaletteItem.test.tsx(jsdom does not implementscrollIntoView).Selector.test.tsxMultiSelector.test.tsxTypeahead.test.tsx(coversBaseTypeahead)Verification
npx tsc --project packages/core/tsconfig.build.json→ exit 0npx eslint <changed files>→ cleannpx vitest run packages/core/src/{Selector,MultiSelector,Typeahead,CommandPalette}→ 9 files, 140 tests passing