Skip to content

Conversation

@atomiks
Copy link
Contributor

@atomiks atomiks commented Jan 22, 2026

This avoids surprises with value getting cleared (to null) when the selected item isn't present in items, particularly in async combobox implementations. Native <select>s retain the previous value in state when the <option> gets removed from the list, with the exception that it automatically selects a fallback value which is a bit confusing here

Fixes #3818
Fixes #3502

@atomiks atomiks added type: bug It doesn't behave as expected. component: combobox Changes related to the combobox component. labels Jan 22, 2026
@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 22, 2026

  • vite-css-base-ui-example

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

commit: dec9923

@mui-bot
Copy link

mui-bot commented Jan 22, 2026

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react ▼-348B(-0.08%) ▼-118B(-0.09%)

Details of bundle changes


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

@netlify
Copy link

netlify bot commented Jan 22, 2026

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit dec9923
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6971d7d34ee6a30008f06f53
😎 Deploy Preview https://deploy-preview-3824--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 marked this pull request as ready for review January 22, 2026 07:59
@greptile-apps
Copy link

greptile-apps bot commented Jan 22, 2026

Greptile Summary

This PR removes the automatic value reconciliation logic that was clearing selected values when the items array changed. The previous behavior was clearing controlled values to null (or filtering out items in multiple mode) when the selected item wasn't present in the items array, which caused issues for async combobox implementations and paginated data scenarios.

  • Removed 46 lines of reconciliation logic from AriaCombobox.tsx that was forcing value clearing
  • Updated test expectations to reflect values persisting when items change
  • Added new test case validating that controlled object values not in items array still display their labels correctly using itemToStringLabel
  • Removed two tests that were validating the old reconciliation behavior

The change aligns with native <select> behavior which retains the previous value when an <option> is removed. The stringifyAsLabel utility already handles displaying labels for values not in the items array by using itemToStringLabel or extracting labels from object structures, ensuring the input displays correctly even when the selected item isn't in the current items list.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The change cleanly removes problematic reconciliation logic that was causing regressions. The implementation is well-supported by the existing stringifyAsLabel utility which handles values not in the items array. Comprehensive tests validate the new behavior, and the approach aligns with native HTML form control behavior.
  • No files require special attention

Important Files Changed

Filename Overview
packages/react/src/combobox/root/AriaCombobox.tsx Removed automatic value reconciliation logic that was clearing selected values when items changed, allowing controlled values to persist even when not in items array
packages/react/src/combobox/root/ComboboxRoot.test.tsx Removed tests for the old reconciliation behavior and added test for showing labels of controlled values not in items array, updated test expectations to match new behavior

Copy link
Contributor

@sarthakmalik0810 sarthakmalik0810 left a comment

Choose a reason for hiding this comment

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

Thank you for the quick fix @atomiks! Since this might have broken async Comboboxes, do you think the release for this fix could be expedited? Many thanks!

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] Value gets cleared when items change [combobox] Combobox.Input value reset on re-renders

3 participants