Skip to content

Conversation

@atomiks
Copy link
Contributor

@atomiks atomiks commented Oct 26, 2025

This improves the virtualized demos when the item values are objects. Three issues were occurring before:

  1. Two passes of filtering was occurring: Added a filteredItems prop to the root components, which overrides the internal filtering. Two passes of filtering was occurring (external + internal) and you needed to pass filter={contains} to sync the internal and external filtering together. This reduces it to one pass and removes this need to sync the filtering.
  2. Object items were serialized slowly: This was the biggest cause of slowness - when using objects in a virtual list, JSON.stringify() serialization was being performed on every single item, which made filtering slow. Now the useFilter hook has the third optional param itemToString in its types (previously it only existed at runtime), which should be passed when externally filtering object items.
  3. Filtering work blocks typing: React.useDeferredValue() can be used to improve typing performance while filtering work is ongoing

Now with 10,000 object items, even with 20x slowdown (M4 Pro), it's speedy:

Screen.Recording.2025-10-27.at.8.26.35.am.mov

@atomiks atomiks added docs Improvements or additions to the documentation. type: bug It doesn't behave as expected. component: autocomplete Changes related to the autocomplete component. component: combobox Changes related to the combobox component. labels Oct 26, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 26, 2025

vite-css-base-ui-example

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

commit: 7535ce2

@mui-bot
Copy link

mui-bot commented Oct 26, 2025

Bundle size report

Bundle Parsed size Gzip size
@base-ui-components/react 🔺+190B(+0.05%) 🔺+14B(+0.01%)

Details of bundle changes


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

@netlify
Copy link

netlify bot commented Oct 26, 2025

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 7535ce2
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6907e700cc49ed000818a04e
😎 Deploy Preview https://deploy-preview-3068--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.

@atomiks atomiks force-pushed the feat/virtualized-filteredItems branch 2 times, most recently from 1816b95 to 98a0757 Compare October 26, 2025 21:23
@atomiks atomiks force-pushed the feat/virtualized-filteredItems branch from 98a0757 to a10dae0 Compare October 26, 2025 21:33
@atomiks atomiks marked this pull request as ready for review October 26, 2025 21:37
Copy link
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

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

Much better 👌

// Floating UI tests don't require `role="row"` wrappers, so retains the number API.
cols: grid ? 2 : 1,
orientation: grid ? 'horizontal' : undefined,
disabledIndices: virtualized
Copy link
Member

Choose a reason for hiding this comment

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

Why was this logic changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not actually necessary, but I was debugging an issue with the virtualized demos which I PR'd here: #3066

@atomiks atomiks requested a review from mnajdova October 30, 2025 10:05
@atomiks atomiks merged commit 565617a into mui:master Nov 2, 2025
20 checks passed
@atomiks atomiks deleted the feat/virtualized-filteredItems branch November 2, 2025 23:32
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. docs Improvements or additions to the documentation. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants