Skip to content

Conversation

rita-codes
Copy link
Member

@rita-codes rita-codes commented Aug 15, 2025

Issue #19191

Repro: select a child so its parent becomes indeterminate, collapse that parent, then expand a different top-level node => the original parent flips to unchecked.

Fix: skip the childrenIds update when the item is collapsed (aria-expanded="false"), preserving previousChildrenIds and the correct indeterminate UI.
Tests: Added regression tests (3-level included)

Before
https://github.com/user-attachments/assets/9e4cdf1f-6438-4474-b2af-429de170d0db

After
https://github.com/user-attachments/assets/941d3b98-9177-4638-be20-03e7e4715737

@rita-codes rita-codes self-assigned this Aug 15, 2025
@rita-codes rita-codes added type: bug It doesn't behave as expected. scope: tree view Changes related to the tree view. This includes TreeView, TreeItem. labels Aug 15, 2025
@mui-bot
Copy link

mui-bot commented Aug 15, 2025

Deploy preview: https://deploy-preview-19196--material-ui-x.netlify.app/

Bundle size report

Bundle Parsed size Gzip size
@mui/x-data-grid 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-pro 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-premium 0B(0.00%) 0B(0.00%)
@mui/x-charts 0B(0.00%) 0B(0.00%)
@mui/x-charts-pro 0B(0.00%) 0B(0.00%)
@mui/x-date-pickers 0B(0.00%) 0B(0.00%)
@mui/x-date-pickers-pro 0B(0.00%) 0B(0.00%)
@mui/x-tree-view 🔺+132B(+0.22%) 🔺+33B(+0.18%)
@mui/x-tree-view-pro 🔺+132B(+0.16%) 🔺+36B(+0.14%)

Details of bundle changes

Generated by 🚫 dangerJS against 0910614

Copy link
Contributor

@noraleonte noraleonte left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this, nice work! 💙

…-parent-is-collapsed-the-parent-node-sometimes-displays-as-unselected
@rita-codes rita-codes merged commit e9bc9be into mui:master Aug 15, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: tree view Changes related to the tree view. This includes TreeView, TreeItem. type: bug It doesn't behave as expected.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[tree view] when child is selected and parent is collapsed, the parent node sometimes displays as unselected
3 participants