Skip to content

Commit 1b4f50b

Browse files
committed
fixup! fix(cdk-experimental/listbox): address comments
1 parent 6c26bf4 commit 1b4f50b

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

src/cdk/collections/selection-model.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ export class SelectionModel<T> {
5858
* Selects a value or an array of values.
5959
* @param values The values to select
6060
* @return Whether the selection changed as a result of this call
61+
* @breaking-change 16.0.0 make return type boolean
6162
*/
62-
select(...values: T[]) {
63+
select(...values: T[]): boolean | void {
6364
this._verifyValueAssignment(values);
6465
values.forEach(value => this._markSelected(value));
6566
const changed = this._hasQueuedChanges();
@@ -71,8 +72,9 @@ export class SelectionModel<T> {
7172
* Deselects a value or an array of values.
7273
* @param values The values to deselect
7374
* @return Whether the selection changed as a result of this call
75+
* @breaking-change 16.0.0 make return type boolean
7476
*/
75-
deselect(...values: T[]) {
77+
deselect(...values: T[]): boolean | void {
7678
this._verifyValueAssignment(values);
7779
values.forEach(value => this._unmarkSelected(value));
7880
const changed = this._hasQueuedChanges();
@@ -84,8 +86,9 @@ export class SelectionModel<T> {
8486
* Sets the selected values
8587
* @param values The new selected values
8688
* @return Whether the selection changed as a result of this call
89+
* @breaking-change 16.0.0 make return type boolean
8790
*/
88-
setSelection(...values: T[]): boolean {
91+
setSelection(...values: T[]): boolean | void {
8992
this._verifyValueAssignment(values);
9093
const oldValues = this.selected;
9194
const newSelectedSet = new Set(values);
@@ -102,8 +105,9 @@ export class SelectionModel<T> {
102105
* Toggles a value between selected and deselected.
103106
* @param value The value to toggle
104107
* @return Whether the selection changed as a result of this call
108+
* @breaking-change 16.0.0 make return type boolean
105109
*/
106-
toggle(value: T) {
110+
toggle(value: T): boolean | void {
107111
return this.isSelected(value) ? this.deselect(value) : this.select(value);
108112
}
109113

@@ -112,8 +116,9 @@ export class SelectionModel<T> {
112116
* @param flushEvent Whether to flush the changes in an event.
113117
* If false, the changes to the selection will be flushed along with the next event.
114118
* @return Whether the selection changed as a result of this call
119+
* @breaking-change 16.0.0 make return type boolean
115120
*/
116-
clear(flushEvent = true) {
121+
clear(flushEvent = true): boolean | void {
117122
this._unmarkAll();
118123
const changed = this._hasQueuedChanges();
119124
if (flushEvent) {

tools/public_api_guard/cdk/collections.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,19 @@ export interface SelectionChange<T> {
7373
export class SelectionModel<T> {
7474
constructor(_multiple?: boolean, initiallySelectedValues?: T[], _emitChanges?: boolean, compareWith?: ((o1: T, o2: T) => boolean) | undefined);
7575
readonly changed: Subject<SelectionChange<T>>;
76-
clear(flushEvent?: boolean): boolean;
76+
clear(flushEvent?: boolean): boolean | void;
7777
// (undocumented)
7878
compareWith?: ((o1: T, o2: T) => boolean) | undefined;
79-
deselect(...values: T[]): boolean;
79+
deselect(...values: T[]): boolean | void;
8080
hasValue(): boolean;
8181
isEmpty(): boolean;
8282
isMultipleSelection(): boolean;
8383
isSelected(value: T): boolean;
84-
select(...values: T[]): boolean;
84+
select(...values: T[]): boolean | void;
8585
get selected(): T[];
86-
setSelection(...values: T[]): boolean;
86+
setSelection(...values: T[]): boolean | void;
8787
sort(predicate?: (a: T, b: T) => number): void;
88-
toggle(value: T): boolean;
88+
toggle(value: T): boolean | void;
8989
}
9090

9191
// @public

0 commit comments

Comments
 (0)