Closed
Description
Is this a regression?
- Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
No response
Description
SelectionModel does not always respect the compareWith
function.
The lines in SelectionModel where it goes wrong:
https://github.com/angular/components/blob/14.1.3/src/cdk/collections/selection-model.ts#L212
https://github.com/angular/components/blob/14.1.3/src/cdk/collections/selection-model.ts#L97
Reproduction
https://stackblitz.com/edit/components-issue-8zah2s?file=src/app/example-component.ts
Steps to reproduce:
- Set up a selection model with multiple selection and
compareWith
function. - Select an item.
- Try to deselect the item but pass a copy of the original item.
Expected Behavior
The item is deselected because it is equal to the original item according to the compareWith
function.
Actual Behavior
The item is not deselected because the current implementation uses Set.delete
to remove the item.
Environment
- Angular: 14.1.3
- CDK/Material: 14.1.3