Skip to content

[combobox] Fix async items while popup is open - #4034

Merged
atomiks merged 2 commits into
mui:masterfrom
atomiks:codex/fix-combobox-async-comparator-crash
Feb 11, 2026
Merged

atomiks merged 2 commits into
mui:masterfrom
atomiks:codex/fix-combobox-async-comparator-crash

Conversation

@atomiks

@atomiks atomiks commented Feb 10, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #4032

  • Guard highlight reconciliation against nullish values by using compareItemEquality before invoking custom isItemEqualToValue
  • Fix controlled async items flow where opening while loading, then selecting after hydration, could leave the list empty on reopen
  • Avoid stale store reads in Combobox.Item by using render-time hasItems

Repro

  1. Open popup while items is undefined.
  2. Hydrate items asynchronously.
  3. Hover and keyboard navigate items.
  4. Ensure custom comparator is never called with nullish args.
  5. Select an item after hydration and reopen the popup.
  6. Verify options are still rendered (no collapse to empty list).

Stackblitz

@mui-bot

mui-bot commented Feb 10, 2026 •

Copy link
Copy Markdown

Bundle size report

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

Details of bundle changes


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

@pkg-pr-new

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

commit: f72f7fe

@greptile-apps

greptile-apps Bot commented Feb 10, 2026

Copy link
Copy Markdown
Contributor

Greptile Overview

Greptile Summary

This PR updates Combobox highlight reconciliation to use compareItemEquality before invoking the user-provided isItemEqualToValue, preventing custom comparators from being called with nullish values during async item hydration.

It also adds a regression test that opens with items={undefined}, hydrates items, then hovers and keyboard-navigates to exercise the highlight logic. However, the new candidate test currently doesn’t assert that the comparator spy is called (and thus doesn’t actually verify the “never called with nullish args” guarantee).

Confidence Score: 4/5

  • Mostly safe to merge, but the added regression test needs tightening to reliably catch the intended bug.
  • The production change is minimal and uses an existing utility (compareItemEquality) that explicitly guards nullish comparisons. The main remaining risk is that the new test is not asserting comparator invocation, so future regressions could slip through unnoticed.
  • packages/react/src/combobox/root/ComboboxRoot.test.tsx

Important Files Changed

Filename Overview
packages/react/src/combobox/root/AriaCombobox.tsx Replaces direct isItemEqualToValue call during highlight reconciliation with compareItemEquality to avoid invoking custom comparators with nullish values.
packages/react/src/combobox/root/ComboboxRoot.test.tsx Adds async-items hydration regression test, but the new test currently doesn’t assert the comparator spy was called (so it won’t fail if the bug regresses).

@atomiks atomiks added the component: combobox Changes related to the combobox component. label Feb 10, 2026

@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, 1 comment

Edit Code Review Agent Settings | Greptile

@atomiks atomiks added the type: bug It doesn't behave as expected. label Feb 10, 2026
@netlify

netlify Bot commented Feb 10, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit f72f7fe
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/698c3aca49e94a0008a173ea
😎 Deploy Preview https://deploy-preview-4034--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 codex/fix-combobox-async-comparator-crash branch 2 times, most recently from f1c46a3 to ee2dd8b Compare February 10, 2026 03:05
@atomiks
atomiks force-pushed the codex/fix-combobox-async-comparator-crash branch from ee2dd8b to 64e1202 Compare February 10, 2026 03:19
@atomiks atomiks changed the title [combobox] Guard highlight comparator after async item load [combobox] Fix async items while popup is open Feb 10, 2026
@atomiks
atomiks merged commit f19c704 into mui:master Feb 11, 2026
7 checks passed
@atomiks
atomiks deleted the codex/fix-combobox-async-comparator-crash branch February 11, 2026 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: combobox Changes related to the combobox component. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[combobox] undefined values after async items load

3 participants