Skip to content

[combobox][autocomplete] Reset list scroll position on filter - #5231

Merged
atomiks merged 9 commits into
mui:masterfrom
atomiks:claude/interesting-hodgkin-1347c0
Jul 15, 2026
Merged

atomiks merged 9 commits into
mui:masterfrom
atomiks:claude/interesting-hodgkin-1347c0

Conversation

@atomiks

@atomiks atomiks commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Closes #5204

When the input value changes and the list re-filters, the scroll position stayed where it was — the user could be left looking at the middle of a fresh result set (and with autoHighlight, the highlighted first item scrolled out of view). Autocomplete, built on the same internals, had the same bug.

On a typed-input change, the nearest list overflow container is now reset directly to the top. It is keyed on the typed-input signal rather than the input value, so inline autocompletion (mode="both"/"inline") rewriting the input during arrow navigation does not reset the scroll. Resetting the container directly avoids scrolling a surrounding dialog or page and does not depend on stale composite registry order when retained items are reordered. Virtualized lists own their scroll element and are left untouched.

Playground: https://stackblitz.com/edit/ouhpah4p?file=src%2FApp.tsx

@atomiks atomiks added type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. component: autocomplete Changes related to the autocomplete component. component: combobox Changes related to the combobox component. labels Jul 14, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
  • base-ui-tanstack-start

  • vite-css-base-ui-example

    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/react@5231
    
    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/utils@5231
    

commit: 02accdd

@code-infra-dashboard

code-infra-dashboard Bot commented Jul 14, 2026 •

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+266B(+0.06%) 🔺+98B(+0.07%)

Details of bundle changes

Performance

Total duration: 1,094.74 ms -12.95 ms(-1.2%) | Renders: 78 (+0) | Paint: 1,676.90 ms -38.97 ms(-2.3%)

No significant changes — details


Check out the code infra dashboard for more information about this PR.

@netlify

netlify Bot commented Jul 14, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 02accdd
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a574ec9c4cc2900072e7ef6
😎 Deploy Preview https://deploy-preview-5231--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a UX bug in Base UI’s Combobox/Autocomplete filtering flow where the list could remain scrolled to a stale position after the query changes, potentially leaving the user looking at the middle of a fresh result set (and hiding the auto-highlighted first item).

Changes:

  • Add a layout-effect-based scroll reset in AriaCombobox that runs on typed input changes and resets the nearest overflow scroll container (skipping virtualized lists).
  • Refactor isScrollable into isScrollableY/isScrollableX helpers to support clearer axis-specific scroll checks.
  • Add browser-only tests for Combobox and Autocomplete covering scroll reset behavior and key edge cases (wrappers, clipping ancestors, reordering, inline mode behavior).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
packages/react/src/utils/scrollable.ts Splits scrollability detection into axis-specific helpers used by scroll-container discovery.
packages/react/src/combobox/root/AriaCombobox.tsx Implements the scroll reset on typed query updates by locating and resetting the nearest vertical scroll container.
packages/react/src/combobox/root/ComboboxRoot.test.tsx Adds browser-mode tests validating scroll reset behavior across several Combobox compositions.
packages/react/src/autocomplete/root/AutocompleteRoot.test.tsx Adds browser-mode tests validating scroll reset and ensuring inline navigation doesn’t trigger resets in mode="both".

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@atomiks
atomiks force-pushed the claude/interesting-hodgkin-1347c0 branch from c2091da to 02accdd Compare July 15, 2026 09:11
@atomiks
atomiks requested a review from Copilot July 15, 2026 09:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@atomiks
atomiks merged commit 370758e into mui:master Jul 15, 2026
7 checks passed
@atomiks
atomiks deleted the claude/interesting-hodgkin-1347c0 branch July 15, 2026 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: autocomplete Changes related to the autocomplete component. component: combobox Changes related to the combobox component. type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[combobox] Reset scroll on input value change

2 participants