Skip to content

[combobox][autocomplete] Add useFilteredItems hook, allowing for simpler implementation of virtualized comboboxes - #3732

Merged
atomiks merged 16 commits into
mui:masterfrom
guisehn:allow-simpler-virtualization
Jan 23, 2026
Merged

atomiks merged 16 commits into
mui:masterfrom
guisehn:allow-simpler-virtualization

Conversation

@guisehn

@guisehn guisehn commented Jan 13, 2026 •

Copy link
Copy Markdown
Contributor

This PR adds a Combobox.useFilteredItems and a Autocomplete.useFilteredItems hook, allowing for simpler implementation of virtualized comboboxes and autocompletes. Solves #3669.

@pkg-pr-new

pkg-pr-new Bot commented Jan 13, 2026 •

Copy link
Copy Markdown
  • vite-css-base-ui-example

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

commit: cf9f2c8

@mui-bot

mui-bot commented Jan 13, 2026 •

Copy link
Copy Markdown

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react 🔺+86B(+0.02%) 🔺+19B(+0.01%)

Details of bundle changes


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

@netlify

netlify Bot commented Jan 13, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit cf9f2c8
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6972e437bab0c80008c51747
😎 Deploy Preview https://deploy-preview-3732--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@greptile-apps

greptile-apps Bot commented Jan 13, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR introduces a new useFilteredItems hook for both Combobox and Autocomplete components, significantly simplifying the implementation of virtualized lists. The hook provides direct access to filtered items from the component context, eliminating the need for manual filtering with useFilter, useDeferredValue, and useMemo.

Key changes:

  • Added Combobox.useFilteredItems<T>() hook that returns filtered items from combobox context
  • Re-exported the hook as Autocomplete.useFilteredItems<T>() for autocomplete component
  • Simplified all virtualized demos by removing ~40 lines of boilerplate filtering code per demo
  • Updated documentation to include the new hook's API reference

Impact:
The change makes virtualization much more accessible to library users by reducing complexity from the consumer's perspective. The demos now show a cleaner separation of concerns with filtering logic handled internally by the component and virtualization logic handled by the consumer.

Confidence Score: 5/5

  • This PR is safe to merge with no issues found
  • The implementation is straightforward and well-executed. The new hook simply exposes existing filtered items from the component context. All demos were consistently updated across both CSS Modules and Tailwind variants. The change is purely additive (no breaking changes), follows existing patterns in the codebase, and significantly improves developer experience.
  • No files require special attention

Important Files Changed

Filename Overview
packages/react/src/combobox/root/utils/useFilteredItems.ts New hook that returns filtered items from combobox context - simple and well-implemented
docs/src/app/(docs)/react/components/combobox/demos/virtualized/css-modules/index.tsx Significantly simplified virtualized combobox demo using new hook, removing manual filtering logic
docs/src/app/(docs)/react/components/autocomplete/demos/virtualized/tailwind/index.tsx Simplified virtualized autocomplete demo (Tailwind version) using new hook

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

2 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

guisehn and others added 2 commits January 13, 2026 12:08
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Signed-off-by: Guilherme Sehn <[email protected]>
@zannager zannager added the component: combobox Changes related to the combobox component. label Jan 14, 2026
@guisehn guisehn changed the title Add Combobox.useFilteredItems hook, allowing for simpler implementation of virtualized comboboxes [combobox] Add useFilteredItems hook, allowing for simpler implementation of virtualized comboboxes Jan 14, 2026
Comment on lines +3 to +5
/**
* Return filtered items from the combobox.
*/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This seems fine to me - unless the list is really huge, I think React.useDeferredValue() can be skipped.

Can you update the Autocomplete demos/API as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Can you update the Autocomplete demos/API as well?

Done! d5e8c73 and 6246b3a

@guisehn guisehn changed the title [combobox] Add useFilteredItems hook, allowing for simpler implementation of virtualized comboboxes [combobox][autocomplete] Add useFilteredItems hook, allowing for simpler implementation of virtualized comboboxes Jan 21, 2026
@atomiks

atomiks commented Jan 21, 2026

Copy link
Copy Markdown
Contributor

@greptileai

@atomiks atomiks added type: new feature Expand the scope of the product to solve a new problem. component: autocomplete Changes related to the autocomplete component. labels Jan 21, 2026
@greptile-apps

greptile-apps Bot commented Jan 21, 2026

Copy link
Copy Markdown
Contributor

Greptile found no issues!

From now on, if a review finishes and we haven't found any issues, we will not post anything, but you can confirm that we reviewed your changes in the status check section.

This feature can be toggled off in your Code Review Settings by deselecting "Create a status check for each PR".

@atomiks
atomiks merged commit 0c8615f into mui:master Jan 23, 2026
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: new feature Expand the scope of the product to solve a new problem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants