Skip to content

[select] Fix dirty state not clearing in multiple mode - #4971

Merged
atomiks merged 2 commits into
mui:masterfrom
atomiks:claude/xenodochial-pascal-b5950b
Jun 10, 2026
Merged

atomiks merged 2 commits into
mui:masterfrom
atomiks:claude/xenodochial-pascal-b5950b

Conversation

@atomiks

@atomiks atomiks commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

In a multiple Select inside a Field, [data-dirty] stayed set after the selection returned to its initial value.

Root cause

The dirty check used value !== validityData.initialValue. In multiple mode value is a fresh array on every change, so the reference comparison was always true once the user interacted — even after deselecting and reselecting back to the initial items.

Changes

  • Compare array values element-by-element via isItemEqualToValue when computing dirty state in multiple mode, falling back to reference comparison for non-array values. This mirrors the equivalent combobox fix.
  • Add regression tests for returning to the initial value, object values compared via isItemEqualToValue, and the order-sensitive case.

Notes

  • The comparison is order-sensitive, matching CheckboxGroup and Slider. Returning to the same items in a different order is still treated as dirty.

@atomiks atomiks added type: bug It doesn't behave as expected. component: select Changes related to the select component. labels Jun 3, 2026
@pkg-pr-new

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

commit: f6f1845

@code-infra-dashboard

code-infra-dashboard Bot commented Jun 3, 2026 •

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+97B(+0.02%) 🔺+33B(+0.02%)

Details of bundle changes

Performance

Total duration: 1,632.21 ms +75.51 ms(+4.9%) | Renders: 50 (+0) | Paint: 2,436.91 ms +106.59 ms(+4.6%)

No significant changes — details


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

@netlify

netlify Bot commented Jun 3, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit f6f1845
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a2909a9d5b977000843396c
😎 Deploy Preview https://deploy-preview-4971--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

@atomiks
atomiks marked this pull request as ready for review June 8, 2026 03:37

atomiks commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

Code Review (GPT-5.5)

Approve ✅ The dirty-state fix is narrowly scoped, uses the existing order-sensitive equality utilities correctly, and the added regression tests cover the important multiple-select cases.

1. Bugs / Issues (None)

No branch-relevant bugs or blocking issues found.

2. Root Cause & Patch Assessment

The patch addresses the actual failure mode: multiple Select values are arrays, so reference comparison kept [data-dirty] set after returning to an equivalent initial value. Comparing array entries through compareItemEquality(..., isItemEqualToValue) preserves object-value support while leaving single-value behavior unchanged.

3. Pattern Consistency Assessment

The order-sensitive comparison is consistent with the existing areArraysEqual usage in CheckboxGroup and Slider, and the object-value path matches Select’s existing isSelected semantics.

4. Test Coverage Assessment

Coverage looks appropriate for this bug fix: it includes returning to the initial primitive value, object values compared through isItemEqualToValue, and the intentional different-order case that should stay dirty.

Validation run:

  • pnpm test:jsdom SelectRoot --no-watch
  • pnpm typescript
  • git diff --check upstream/master...upstream/pr/4971

@atomiks
atomiks merged commit 900210a into mui:master Jun 10, 2026
6 checks passed
@atomiks
atomiks deleted the claude/xenodochial-pascal-b5950b branch June 10, 2026 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant