From 84a181be765dae4b7744906f173d8a4ba9a39412 Mon Sep 17 00:00:00 2001 From: Pascal Weyrich Date: Wed, 6 Apr 2022 21:30:44 +0200 Subject: [PATCH 1/2] fix(material/list): wrong order of arguments when calling custom compareWith function Fixes a bug in Angular Material `selection-list` component where the order of arguments passed to a custom compareWith function was mixed up during initialization of a MatListOption. Expected order based on documentation is: 1. value of the respective option 2. value of the selection --- src/material/list/selection-list.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/material/list/selection-list.ts b/src/material/list/selection-list.ts index ccf02ab1fb1a..e7f5206d8886 100644 --- a/src/material/list/selection-list.ts +++ b/src/material/list/selection-list.ts @@ -205,7 +205,7 @@ export class MatListOption ngOnInit() { const list = this.selectionList; - if (list._value && list._value.some(value => list.compareWith(value, this._value))) { + if (list._value && list._value.some(value => list.compareWith(this._value, value))) { this._setSelected(true); } From 553f013a0bd67e074a679ab41686f23ae90caeff Mon Sep 17 00:00:00 2001 From: Pascal Weyrich Date: Thu, 7 Apr 2022 14:45:37 +0200 Subject: [PATCH 2/2] fix(material-experimental/mdc-list): wrong order of arguments when calling custom compareWith function Fixes a bug in Angular Material's experimental mdc-selection-list component where the order of arguments passed to a custom compareWith function was mixed up during initialization of a MatListOption. Expected order based on documentation is: 1. value of the respective option 2. value of the selection --- src/material-experimental/mdc-list/list-option.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/material-experimental/mdc-list/list-option.ts b/src/material-experimental/mdc-list/list-option.ts index 89b9de13b32c..42a15921f07e 100644 --- a/src/material-experimental/mdc-list/list-option.ts +++ b/src/material-experimental/mdc-list/list-option.ts @@ -179,7 +179,7 @@ export class MatListOption extends MatListItemBase implements ListOption, OnInit ngOnInit() { const list = this._selectionList; - if (list._value && list._value.some(value => list.compareWith(value, this._value))) { + if (list._value && list._value.some(value => list.compareWith(this._value, value))) { this._setSelected(true); }