Skip to content

Commit 442f335

Browse files
committed
refactor(material/list): remove deprecated APIs for v12
Cleans up the deprecated APIs for v12 from the `material/list` package. BREAKING CHANGES: * The `mat-list-item-avatar` CSS class has been replaced with `mat-list-item-with-avatar`. * `MatSelectionListChange.option` has been removed. Use `MatSelectionListChange.options` instead. * `MatListItemHarnessBase.getHarnessLoaderForContent` has been removed. Use `MatListItemHarnessBase.getChildLoader(MatListItemSection.CONTENT)` instead. * The `tabIndex` input has been removed from `MatSelectionList`. * The `MatSelectionList` constructor has been changed to remove the `tabIndex` parameter and to turn `_focusMonitor` into a required parameter.
1 parent 8eb59f8 commit 442f335

File tree

8 files changed

+46
-48
lines changed

8 files changed

+46
-48
lines changed

src/material-experimental/mdc-list/selection-list.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,6 @@ export class MatSelectionListChange {
4646
constructor(
4747
/** Reference to the selection list that emitted the event. */
4848
public source: MatSelectionList,
49-
/**
50-
* Reference to the option that has been changed.
51-
* @deprecated Use `options` instead, because some events may change more than one option.
52-
* @breaking-change 12.0.0
53-
*/
54-
public option: MatListOption,
5549
/** Reference to the options that have been changed. */
5650
public options: MatListOption[]) {}
5751
}
@@ -216,7 +210,7 @@ export class MatSelectionList extends MatInteractiveListBase<MatListOption>
216210

217211
/** Emits a change event if the selected state of an option changed. */
218212
_emitChangeEvent(options: MatListOption[]) {
219-
this.selectionChange.emit(new MatSelectionListChange(this, options[0], options));
213+
this.selectionChange.emit(new MatSelectionListChange(this, options));
220214
}
221215

222216
/** Implemented as part of ControlValueAccessor. */

src/material/list/list.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,6 @@ export class MatListSubheaderCssMatStyler {}
184184
host: {
185185
'class': 'mat-list-item mat-focus-indicator',
186186
'[class.mat-list-item-disabled]': 'disabled',
187-
// @breaking-change 8.0.0 Remove `mat-list-item-avatar` in favor of `mat-list-item-with-avatar`.
188-
'[class.mat-list-item-avatar]': '_avatar || _icon',
189187
'[class.mat-list-item-with-avatar]': '_avatar || _icon',
190188
},
191189
inputs: ['disableRipple'],

src/material/list/selection-list.ts

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import {
1919
} from '@angular/cdk/keycodes';
2020
import {
2121
AfterContentInit,
22-
Attribute,
2322
ChangeDetectionStrategy,
2423
ChangeDetectorRef,
2524
Component,
@@ -72,12 +71,6 @@ export class MatSelectionListChange {
7271
constructor(
7372
/** Reference to the selection list that emitted the event. */
7473
public source: MatSelectionList,
75-
/**
76-
* Reference to the option that has been changed.
77-
* @deprecated Use `options` instead, because some events may change more than one option.
78-
* @breaking-change 12.0.0
79-
*/
80-
public option: MatListOption,
8174
/** Reference to the options that have been changed. */
8275
public options: MatListOption[]) {}
8376
}
@@ -358,12 +351,6 @@ export class MatSelectionList extends _MatSelectionListMixinBase implements CanD
358351
@Output() readonly selectionChange: EventEmitter<MatSelectionListChange> =
359352
new EventEmitter<MatSelectionListChange>();
360353

361-
/**
362-
* Tabindex of the selection list.
363-
* @breaking-change 11.0.0 Remove `tabIndex` input.
364-
*/
365-
@Input() tabIndex: number = 0;
366-
367354
/** Theme color of the selection list. This sets the checkbox color for all list options. */
368355
@Input() color: ThemePalette = 'accent';
369356

@@ -427,11 +414,8 @@ export class MatSelectionList extends _MatSelectionListMixinBase implements CanD
427414
private _isDestroyed: boolean;
428415

429416
constructor(private _element: ElementRef<HTMLElement>,
430-
// @breaking-change 11.0.0 Remove `tabIndex` parameter.
431-
@Attribute('tabindex') tabIndex: string,
432-
private _changeDetector: ChangeDetectorRef,
433-
// @breaking-change 11.0.0 `_focusMonitor` parameter to become required.
434-
private _focusMonitor?: FocusMonitor) {
417+
private _changeDetector: ChangeDetectorRef,
418+
private _focusMonitor: FocusMonitor) {
435419
super();
436420
}
437421

@@ -476,8 +460,7 @@ export class MatSelectionList extends _MatSelectionListMixinBase implements CanD
476460
}
477461
});
478462

479-
// @breaking-change 11.0.0 Remove null assertion once _focusMonitor is required.
480-
this._focusMonitor?.monitor(this._element)
463+
this._focusMonitor.monitor(this._element)
481464
.pipe(takeUntil(this._destroyed))
482465
.subscribe(origin => {
483466
if (origin === 'keyboard' || origin === 'program') {
@@ -505,8 +488,7 @@ export class MatSelectionList extends _MatSelectionListMixinBase implements CanD
505488
}
506489

507490
ngOnDestroy() {
508-
// @breaking-change 11.0.0 Remove null assertion once _focusMonitor is required.
509-
this._focusMonitor?.stopMonitoring(this._element);
491+
this._focusMonitor.stopMonitoring(this._element);
510492
this._destroyed.next();
511493
this._destroyed.complete();
512494
this._isDestroyed = true;
@@ -599,7 +581,7 @@ export class MatSelectionList extends _MatSelectionListMixinBase implements CanD
599581

600582
/** Emits a change event if the selected state of an option changed. */
601583
_emitChangeEvent(options: MatListOption[]) {
602-
this.selectionChange.emit(new MatSelectionListChange(this, options[0], options));
584+
this.selectionChange.emit(new MatSelectionListChange(this, options));
603585
}
604586

605587
/** Implemented as part of ControlValueAccessor. */

src/material/list/testing/list-item-harness-base.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import {
1010
ComponentHarness,
1111
ComponentHarnessConstructor,
12-
HarnessLoader,
1312
HarnessPredicate,
1413
ContentContainerComponentHarness,
1514
parallel,
@@ -88,13 +87,4 @@ export abstract class MatListItemHarnessBase
8887
async hasIcon(): Promise<boolean> {
8988
return !!await this._icon();
9089
}
91-
92-
/**
93-
* Gets a `HarnessLoader` used to get harnesses within the list item's content.
94-
* @deprecated Use `getChildLoader(MatListItemSection.CONTENT)` or `getHarness` instead.
95-
* @breaking-change 12.0.0
96-
*/
97-
async getHarnessLoaderForContent(): Promise<HarnessLoader> {
98-
return this.getChildLoader(MatListItemSection.CONTENT);
99-
}
10090
}

src/material/schematics/ng-update/data/constructor-checks.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ export const constructorChecks: VersionChanges<ConstructorChecksUpgradeData> = {
1818
{
1919
pr: 'https://github.com/angular/components/pull/21897',
2020
changes: ['MatTooltip']
21+
},
22+
{
23+
pr: 'https://github.com/angular/components/issues/21974',
24+
changes: ['MatSelectionList']
2125
}
2226
],
2327
[TargetVersion.V11]: [

src/material/schematics/ng-update/data/css-selectors.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ export interface MaterialCssSelectorData {
2828
}
2929

3030
export const cssSelectors: VersionChanges<MaterialCssSelectorData> = {
31+
[TargetVersion.V12]: [
32+
{
33+
pr: 'https://github.com/angular/components/issues/21974',
34+
changes: [
35+
{replace: '.mat-list-item-avatar', replaceWith: '.mat-list-item-with-avatar'}
36+
]
37+
}
38+
],
3139
[TargetVersion.V6]: [
3240
{
3341
pr: 'https://github.com/angular/components/pull/10296',

src/material/schematics/ng-update/data/property-names.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,31 @@
99
import {PropertyNameUpgradeData, TargetVersion, VersionChanges} from '@angular/cdk/schematics';
1010

1111
export const propertyNames: VersionChanges<PropertyNameUpgradeData> = {
12+
[TargetVersion.V12]: [
13+
{
14+
pr: 'https://github.com/angular/components/issues/21974',
15+
changes: [
16+
{
17+
replace: 'option',
18+
replaceWith: 'options',
19+
limitedTo: {classes: ['MatSelectionListChange']}
20+
},
21+
{
22+
replace: 'getHarnessLoaderForContent',
23+
replaceWith: 'getChildLoader',
24+
limitedTo: {
25+
classes: [
26+
'MatListItemHarnessBase',
27+
'MatActionListItemHarness',
28+
'MatListItemHarness',
29+
'MatNavListItemHarness',
30+
'MatListOptionHarness'
31+
]
32+
}
33+
}
34+
]
35+
}
36+
],
1237
[TargetVersion.V11]: [
1338
{
1439
pr: 'https://github.com/angular/components/pull/20449',

tools/public_api_guard/material/list.d.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,7 @@ export declare class MatSelectionList extends _MatSelectionListMixinBase impleme
116116
options: QueryList<MatListOption>;
117117
selectedOptions: SelectionModel<MatListOption>;
118118
readonly selectionChange: EventEmitter<MatSelectionListChange>;
119-
tabIndex: number;
120-
constructor(_element: ElementRef<HTMLElement>, tabIndex: string, _changeDetector: ChangeDetectorRef, _focusMonitor?: FocusMonitor | undefined);
119+
constructor(_element: ElementRef<HTMLElement>, _changeDetector: ChangeDetectorRef, _focusMonitor: FocusMonitor);
121120
_emitChangeEvent(options: MatListOption[]): void;
122121
_keydown(event: KeyboardEvent): void;
123122
_removeOptionFromList(option: MatListOption): MatListOption | null;
@@ -136,16 +135,14 @@ export declare class MatSelectionList extends _MatSelectionListMixinBase impleme
136135
static ngAcceptInputType_disableRipple: BooleanInput;
137136
static ngAcceptInputType_disabled: BooleanInput;
138137
static ngAcceptInputType_multiple: BooleanInput;
139-
static ɵcmp: i0.ɵɵComponentDefWithMeta<MatSelectionList, "mat-selection-list", ["matSelectionList"], { "disableRipple": "disableRipple"; "tabIndex": "tabIndex"; "color": "color"; "compareWith": "compareWith"; "disabled": "disabled"; "multiple": "multiple"; }, { "selectionChange": "selectionChange"; }, ["options"], ["*"]>;
140-
static ɵfac: i0.ɵɵFactoryDef<MatSelectionList, [null, { attribute: "tabindex"; }, null, null]>;
138+
static ɵcmp: i0.ɵɵComponentDefWithMeta<MatSelectionList, "mat-selection-list", ["matSelectionList"], { "disableRipple": "disableRipple"; "color": "color"; "compareWith": "compareWith"; "disabled": "disabled"; "multiple": "multiple"; }, { "selectionChange": "selectionChange"; }, ["options"], ["*"]>;
139+
static ɵfac: i0.ɵɵFactoryDef<MatSelectionList, never>;
141140
}
142141

143142
export declare class MatSelectionListChange {
144-
option: MatListOption;
145143
options: MatListOption[];
146144
source: MatSelectionList;
147145
constructor(
148146
source: MatSelectionList,
149-
option: MatListOption,
150147
options: MatListOption[]);
151148
}

0 commit comments

Comments
 (0)