Skip to content

[autocomplete] Fix filter method's useMemo dependency - #3862

Merged
ZeeshanTamboli merged 1 commit into
mui:masterfrom
ZeeshanTamboli:autocomplete-update-baseFilter-useMemo-dependency
Jan 26, 2026
Merged

ZeeshanTamboli merged 1 commit into
mui:masterfrom
ZeeshanTamboli:autocomplete-update-baseFilter-useMemo-dependency

Conversation

@ZeeshanTamboli

@ZeeshanTamboli ZeeshanTamboli commented Jan 26, 2026 •

Copy link
Copy Markdown
Member

This memo would run on every render because other is a new object every render (because of {...other} via props destructuring). This PR fixes the dependency.

@ZeeshanTamboli ZeeshanTamboli 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. labels Jan 26, 2026
@ZeeshanTamboli ZeeshanTamboli changed the title [autocomplete] Fix filter useMemo dependency [autocomplete] Fix filter method's useMemo dependency Jan 26, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jan 26, 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@3862
    
    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/utils@3862
    

commit: a223612

@mui-bot

mui-bot commented Jan 26, 2026 •

Copy link
Copy Markdown

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react 🔺+7B(0.00%) 🔺+2B(0.00%)

Details of bundle changes


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

@netlify

netlify Bot commented Jan 26, 2026

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit a223612
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/69774663f9cacd0008383308
😎 Deploy Preview https://deploy-preview-3862--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.

@ZeeshanTamboli
ZeeshanTamboli marked this pull request as ready for review January 26, 2026 10:51
@greptile-apps

greptile-apps Bot commented Jan 26, 2026

Copy link
Copy Markdown
Contributor

Greptile Overview

Greptile Summary

This PR fixes a performance issue in the AutocompleteRoot component where the baseFilter useMemo hook was being re-computed on every render. The fix changes the dependency array from [other, collator] to [other.filter, collator], since other is a new object on every render due to props destructuring.

  • Fixed unnecessary re-computation of baseFilter memo by using other.filter instead of the entire other object in the dependency array
  • The change is correct because the memo only uses other.filter from the other object

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • The change is a focused performance optimization that correctly fixes a useMemo dependency issue. The fix only extracts the specific property (other.filter) that is actually used in the memo, preventing unnecessary re-computation while maintaining the same functionality.
  • No files require special attention

Important Files Changed

Filename Overview
packages/react/src/autocomplete/root/AutocompleteRoot.tsx Fixed useMemo dependency from other object to other.filter to prevent unnecessary re-computation on every render

@ZeeshanTamboli
ZeeshanTamboli merged commit 411371a into mui:master Jan 26, 2026
@ZeeshanTamboli
ZeeshanTamboli deleted the autocomplete-update-baseFilter-useMemo-dependency branch January 26, 2026 11:32
atomiks pushed a commit to atomiks/base-ui that referenced this pull request Jan 28, 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. 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.

3 participants