Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DataGrid] Fix checkbox selection keeping selection when filtering #11751

Conversation

g1mishra
Copy link
Contributor

@g1mishra g1mishra commented Jan 19, 2024

Fixes #11726

Preview https://deploy-preview-11751--material-ui-x.netlify.app/x/react-data-grid/row-selection/#checkbox-selection

Issue:
When all rows were selected, and a filter was applied, the handleHeaderSelectionCheckboxChange function's onClick event for the allSelect checkbox was deselecting only the filtered rows. Non-filtered selected rows were retained in the state.

Solution:
To address this issue, modifications were made to the handleHeaderSelectionCheckboxChange function. With a filter applied, I pass the third argument to selectRows to ensure that deselection also considers non-filtered selected rows.

@mui-bot
Copy link

mui-bot commented Jan 19, 2024

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

Generated by 🚫 dangerJS against 72d6e88

@zannager zannager added the component: data grid This is the name of the generic UI component, not the React module! label Jan 19, 2024
@michelengelen michelengelen added feature: Filtering Related to the data grid Filtering feature feature: Selection Related to the data grid Selection feature labels Feb 5, 2024
@michelengelen
Copy link
Member

Thanks @g1mishra for the contribution.
Would you mind adding a test for this? Thanks! 🙇🏼

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 7, 2024
Copy link

github-actions bot commented Feb 7, 2024

This pull request has conflicts, please resolve those before we can evaluate the pull request.

1 similar comment
Copy link

github-actions bot commented Feb 7, 2024

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 11, 2024
@cherniavskii cherniavskii added bug 🐛 Something doesn't work needs cherry-pick The PR should be cherry-picked to master after merge labels Mar 18, 2024
Copy link
Member

@cherniavskii cherniavskii 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!

@cherniavskii cherniavskii merged commit a764d21 into mui:next Mar 18, 2024
17 checks passed
github-actions bot pushed a commit that referenced this pull request Mar 18, 2024
Co-authored-by: Andrew Cherniavskyi <andrew@mui.com>
@cherniavskii cherniavskii changed the title Fix checkbox selection is keeping selection when filtering [DataGrid] Fix checkbox selection keeping selection when filtering Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! feature: Filtering Related to the data grid Filtering feature feature: Selection Related to the data grid Selection feature needs cherry-pick The PR should be cherry-picked to master after merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[data grid] Checkbox selection is keeping selection when filtering
5 participants