Skip to content

Commit 33d7418

Browse files
committed
refactor(material/list): remove deprecated APIs for version 13
Removes the APIs that were marked for removal in version 13 in the `material/list` package. BREAKING CHANGE: * `mat-list-item-avatar` CSS class has been renamed to `mat-list-item-with-avatar`. * `MatSelectionListChange.option` has been removed. Use `MatSelectionListChange.options` instead. * `MatSelectionList.tabIndex` input has been removed. * `tabIndex` parameter of the `MatSelectionList` constructor has been removed. * `_focusMonitor` parameter of the `MatSelectionList` constructor is now required. * `getHarnessLoaderForContent` has been removed from the various test item harnesses. Use `getChildLoader(MatListItemSection.CONTENT)` instead.
1 parent 03485cd commit 33d7418

File tree

7 files changed

+19
-42
lines changed

7 files changed

+19
-42
lines changed

src/material/list/list.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,6 @@ export class MatListSubheaderCssMatStyler {}
176176
host: {
177177
'class': 'mat-list-item mat-focus-indicator',
178178
'[class.mat-list-item-disabled]': 'disabled',
179-
// @breaking-change 8.0.0 Remove `mat-list-item-avatar` in favor of `mat-list-item-with-avatar`.
180-
'[class.mat-list-item-avatar]': '_avatar || _icon',
181179
'[class.mat-list-item-with-avatar]': '_avatar || _icon',
182180
},
183181
inputs: ['disableRipple'],

src/material/list/selection-list.ts

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {SelectionModel} from '@angular/cdk/collections';
1212
import {A, DOWN_ARROW, ENTER, hasModifierKey, SPACE, UP_ARROW} from '@angular/cdk/keycodes';
1313
import {
1414
AfterContentInit,
15-
Attribute,
1615
ChangeDetectionStrategy,
1716
ChangeDetectorRef,
1817
Component,
@@ -59,12 +58,6 @@ export class MatSelectionListChange {
5958
constructor(
6059
/** Reference to the selection list that emitted the event. */
6160
public source: MatSelectionList,
62-
/**
63-
* Reference to the option that has been changed.
64-
* @deprecated Use `options` instead, because some events may change more than one option.
65-
* @breaking-change 12.0.0
66-
*/
67-
public option: MatListOption,
6861
/** Reference to the options that have been changed. */
6962
public options: MatListOption[],
7063
) {}
@@ -368,12 +361,6 @@ export class MatSelectionList
368361
@Output() readonly selectionChange: EventEmitter<MatSelectionListChange> =
369362
new EventEmitter<MatSelectionListChange>();
370363

371-
/**
372-
* Tabindex of the selection list.
373-
* @breaking-change 11.0.0 Remove `tabIndex` input.
374-
*/
375-
@Input() tabIndex: number = 0;
376-
377364
/** Theme color of the selection list. This sets the checkbox color for all list options. */
378365
@Input() color: ThemePalette = 'accent';
379366

@@ -443,11 +430,8 @@ export class MatSelectionList
443430

444431
constructor(
445432
private _element: ElementRef<HTMLElement>,
446-
// @breaking-change 11.0.0 Remove `tabIndex` parameter.
447-
@Attribute('tabindex') tabIndex: string,
448433
private _changeDetector: ChangeDetectorRef,
449-
// @breaking-change 11.0.0 `_focusMonitor` parameter to become required.
450-
private _focusMonitor?: FocusMonitor,
434+
private _focusMonitor: FocusMonitor,
451435
) {
452436
super();
453437
}
@@ -493,9 +477,8 @@ export class MatSelectionList
493477
}
494478
});
495479

496-
// @breaking-change 11.0.0 Remove null assertion once _focusMonitor is required.
497480
this._focusMonitor
498-
?.monitor(this._element)
481+
.monitor(this._element)
499482
.pipe(takeUntil(this._destroyed))
500483
.subscribe(origin => {
501484
if (origin === 'keyboard' || origin === 'program') {
@@ -524,8 +507,7 @@ export class MatSelectionList
524507
}
525508

526509
ngOnDestroy() {
527-
// @breaking-change 11.0.0 Remove null assertion once _focusMonitor is required.
528-
this._focusMonitor?.stopMonitoring(this._element);
510+
this._focusMonitor.stopMonitoring(this._element);
529511
this._destroyed.next();
530512
this._destroyed.complete();
531513
this._isDestroyed = true;
@@ -626,7 +608,7 @@ export class MatSelectionList
626608

627609
/** Emits a change event if the selected state of an option changed. */
628610
_emitChangeEvent(options: MatListOption[]) {
629-
this.selectionChange.emit(new MatSelectionListChange(this, options[0], options));
611+
this.selectionChange.emit(new MatSelectionListChange(this, options));
630612
}
631613

632614
/** 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,
@@ -91,13 +90,4 @@ export abstract class MatListItemHarnessBase extends ContentContainerComponentHa
9190
async hasIcon(): Promise<boolean> {
9291
return !!(await this._icon());
9392
}
94-
95-
/**
96-
* Gets a `HarnessLoader` used to get harnesses within the list item's content.
97-
* @deprecated Use `getChildLoader(MatListItemSection.CONTENT)` or `getHarness` instead.
98-
* @breaking-change 12.0.0
99-
*/
100-
async getHarnessLoaderForContent(): Promise<HarnessLoader> {
101-
return this.getChildLoader(MatListItemSection.CONTENT);
102-
}
10393
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ export const constructorChecks: VersionChanges<ConstructorChecksUpgradeData> = {
2323
pr: 'https://github.com/angular/components/pull/23573',
2424
changes: ['MatDatepicker', 'MatDateRangePicker'],
2525
},
26+
{
27+
pr: 'https://github.com/angular/components/pull/23327',
28+
changes: ['MatSelectionList', 'MatSelectionListChange'],
29+
},
2630
],
2731
[TargetVersion.V12]: [
2832
{

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.V13]: [
32+
{
33+
pr: 'https://github.com/angular/components/pull/23327',
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',

tools/public_api_guard/material/list-testing.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { ComponentHarness } from '@angular/cdk/testing';
99
import { ComponentHarnessConstructor } from '@angular/cdk/testing';
1010
import { ContentContainerComponentHarness } from '@angular/cdk/testing';
1111
import { DividerHarnessFilters } from '@angular/material/divider/testing';
12-
import { HarnessLoader } from '@angular/cdk/testing';
1312
import { HarnessPredicate } from '@angular/cdk/testing';
1413
import { MatDividerHarness } from '@angular/material/divider/testing';
1514
import { MatListOptionCheckboxPosition } from '@angular/material/list';

tools/public_api_guard/material/list.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export class MatNavList extends _MatListBase implements CanDisable, CanDisableRi
179179

180180
// @public
181181
export class MatSelectionList extends _MatSelectionListBase implements CanDisableRipple, AfterContentInit, ControlValueAccessor, OnDestroy, OnChanges {
182-
constructor(_element: ElementRef<HTMLElement>, tabIndex: string, _changeDetector: ChangeDetectorRef, _focusMonitor?: FocusMonitor | undefined);
182+
constructor(_element: ElementRef<HTMLElement>, _changeDetector: ChangeDetectorRef, _focusMonitor: FocusMonitor);
183183
color: ThemePalette;
184184
compareWith: (o1: any, o2: any) => boolean;
185185
deselectAll(): MatListOption[];
@@ -208,24 +208,20 @@ export class MatSelectionList extends _MatSelectionListBase implements CanDisabl
208208
readonly selectionChange: EventEmitter<MatSelectionListChange>;
209209
setDisabledState(isDisabled: boolean): void;
210210
_setFocusedOption(option: MatListOption): void;
211-
tabIndex: number;
212211
_tabIndex: number;
213212
_value: string[] | null;
214213
writeValue(values: string[]): void;
215214
// (undocumented)
216-
static ɵcmp: i0.ɵɵComponentDeclaration<MatSelectionList, "mat-selection-list", ["matSelectionList"], { "disableRipple": "disableRipple"; "tabIndex": "tabIndex"; "color": "color"; "compareWith": "compareWith"; "disabled": "disabled"; "multiple": "multiple"; }, { "selectionChange": "selectionChange"; }, ["options"], ["*"]>;
215+
static ɵcmp: i0.ɵɵComponentDeclaration<MatSelectionList, "mat-selection-list", ["matSelectionList"], { "disableRipple": "disableRipple"; "color": "color"; "compareWith": "compareWith"; "disabled": "disabled"; "multiple": "multiple"; }, { "selectionChange": "selectionChange"; }, ["options"], ["*"]>;
217216
// (undocumented)
218-
static ɵfac: i0.ɵɵFactoryDeclaration<MatSelectionList, [null, { attribute: "tabindex"; }, null, null]>;
217+
static ɵfac: i0.ɵɵFactoryDeclaration<MatSelectionList, never>;
219218
}
220219

221220
// @public
222221
export class MatSelectionListChange {
223222
constructor(
224223
source: MatSelectionList,
225-
option: MatListOption,
226224
options: MatListOption[]);
227-
// @deprecated
228-
option: MatListOption;
229225
options: MatListOption[];
230226
source: MatSelectionList;
231227
}

0 commit comments

Comments
 (0)