Skip to content

refactor(material/list): remove deprecated APIs for v12 #21974

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions src/material-experimental/mdc-list/selection-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@ export class MatSelectionListChange {
constructor(
/** Reference to the selection list that emitted the event. */
public source: MatSelectionList,
/**
* Reference to the option that has been changed.
* @deprecated Use `options` instead, because some events may change more than one option.
* @breaking-change 12.0.0
*/
public option: MatListOption,
/** Reference to the options that have been changed. */
public options: MatListOption[]) {}
}
Expand Down Expand Up @@ -216,7 +210,7 @@ export class MatSelectionList extends MatInteractiveListBase<MatListOption>

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

/** Implemented as part of ControlValueAccessor. */
Expand Down
2 changes: 0 additions & 2 deletions src/material/list/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,6 @@ export class MatListSubheaderCssMatStyler {}
host: {
'class': 'mat-list-item mat-focus-indicator',
'[class.mat-list-item-disabled]': 'disabled',
// @breaking-change 8.0.0 Remove `mat-list-item-avatar` in favor of `mat-list-item-with-avatar`.
'[class.mat-list-item-avatar]': '_avatar || _icon',
'[class.mat-list-item-with-avatar]': '_avatar || _icon',
},
inputs: ['disableRipple'],
Expand Down
28 changes: 5 additions & 23 deletions src/material/list/selection-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
} from '@angular/cdk/keycodes';
import {
AfterContentInit,
Attribute,
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
Expand Down Expand Up @@ -72,12 +71,6 @@ export class MatSelectionListChange {
constructor(
/** Reference to the selection list that emitted the event. */
public source: MatSelectionList,
/**
* Reference to the option that has been changed.
* @deprecated Use `options` instead, because some events may change more than one option.
* @breaking-change 12.0.0
*/
public option: MatListOption,
/** Reference to the options that have been changed. */
public options: MatListOption[]) {}
}
Expand Down Expand Up @@ -358,12 +351,6 @@ export class MatSelectionList extends _MatSelectionListMixinBase implements CanD
@Output() readonly selectionChange: EventEmitter<MatSelectionListChange> =
new EventEmitter<MatSelectionListChange>();

/**
* Tabindex of the selection list.
* @breaking-change 11.0.0 Remove `tabIndex` input.
*/
@Input() tabIndex: number = 0;

/** Theme color of the selection list. This sets the checkbox color for all list options. */
@Input() color: ThemePalette = 'accent';

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

constructor(private _element: ElementRef<HTMLElement>,
// @breaking-change 11.0.0 Remove `tabIndex` parameter.
@Attribute('tabindex') tabIndex: string,
private _changeDetector: ChangeDetectorRef,
// @breaking-change 11.0.0 `_focusMonitor` parameter to become required.
private _focusMonitor?: FocusMonitor) {
private _changeDetector: ChangeDetectorRef,
private _focusMonitor: FocusMonitor) {
super();
}

Expand Down Expand Up @@ -476,8 +460,7 @@ export class MatSelectionList extends _MatSelectionListMixinBase implements CanD
}
});

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

ngOnDestroy() {
// @breaking-change 11.0.0 Remove null assertion once _focusMonitor is required.
this._focusMonitor?.stopMonitoring(this._element);
this._focusMonitor.stopMonitoring(this._element);
this._destroyed.next();
this._destroyed.complete();
this._isDestroyed = true;
Expand Down Expand Up @@ -599,7 +581,7 @@ export class MatSelectionList extends _MatSelectionListMixinBase implements CanD

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

/** Implemented as part of ControlValueAccessor. */
Expand Down
10 changes: 0 additions & 10 deletions src/material/list/testing/list-item-harness-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import {
ComponentHarness,
ComponentHarnessConstructor,
HarnessLoader,
HarnessPredicate,
ContentContainerComponentHarness,
parallel,
Expand Down Expand Up @@ -88,13 +87,4 @@ export abstract class MatListItemHarnessBase
async hasIcon(): Promise<boolean> {
return !!await this._icon();
}

/**
* Gets a `HarnessLoader` used to get harnesses within the list item's content.
* @deprecated Use `getChildLoader(MatListItemSection.CONTENT)` or `getHarness` instead.
* @breaking-change 12.0.0
*/
async getHarnessLoaderForContent(): Promise<HarnessLoader> {
return this.getChildLoader(MatListItemSection.CONTENT);
}
}
4 changes: 4 additions & 0 deletions src/material/schematics/ng-update/data/constructor-checks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export const constructorChecks: VersionChanges<ConstructorChecksUpgradeData> = {
{
pr: 'https://github.com/angular/components/issues/21900',
changes: ['MatVerticalStepper', 'MatStep']
},
{
pr: 'https://github.com/angular/components/issues/21974',
changes: ['MatSelectionList']
}
],
[TargetVersion.V11]: [
Expand Down
8 changes: 8 additions & 0 deletions src/material/schematics/ng-update/data/css-selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ export interface MaterialCssSelectorData {
}

export const cssSelectors: VersionChanges<MaterialCssSelectorData> = {
[TargetVersion.V12]: [
{
pr: 'https://github.com/angular/components/issues/21974',
changes: [
{replace: '.mat-list-item-avatar', replaceWith: '.mat-list-item-with-avatar'}
]
}
],
[TargetVersion.V6]: [
{
pr: 'https://github.com/angular/components/pull/10296',
Expand Down
25 changes: 25 additions & 0 deletions src/material/schematics/ng-update/data/property-names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,31 @@
import {PropertyNameUpgradeData, TargetVersion, VersionChanges} from '@angular/cdk/schematics';

export const propertyNames: VersionChanges<PropertyNameUpgradeData> = {
[TargetVersion.V12]: [
{
pr: 'https://github.com/angular/components/issues/21974',
changes: [
{
replace: 'option',
replaceWith: 'options',
limitedTo: {classes: ['MatSelectionListChange']}
},
{
replace: 'getHarnessLoaderForContent',
replaceWith: 'getChildLoader',
limitedTo: {
classes: [
'MatListItemHarnessBase',
'MatActionListItemHarness',
'MatListItemHarness',
'MatNavListItemHarness',
'MatListOptionHarness'
]
}
}
]
}
],
[TargetVersion.V11]: [
{
pr: 'https://github.com/angular/components/pull/20449',
Expand Down
9 changes: 3 additions & 6 deletions tools/public_api_guard/material/list.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ export declare class MatSelectionList extends _MatSelectionListMixinBase impleme
options: QueryList<MatListOption>;
selectedOptions: SelectionModel<MatListOption>;
readonly selectionChange: EventEmitter<MatSelectionListChange>;
tabIndex: number;
constructor(_element: ElementRef<HTMLElement>, tabIndex: string, _changeDetector: ChangeDetectorRef, _focusMonitor?: FocusMonitor | undefined);
constructor(_element: ElementRef<HTMLElement>, _changeDetector: ChangeDetectorRef, _focusMonitor: FocusMonitor);
_emitChangeEvent(options: MatListOption[]): void;
_keydown(event: KeyboardEvent): void;
_removeOptionFromList(option: MatListOption): MatListOption | null;
Expand All @@ -137,16 +136,14 @@ export declare class MatSelectionList extends _MatSelectionListMixinBase impleme
static ngAcceptInputType_disableRipple: BooleanInput;
static ngAcceptInputType_disabled: BooleanInput;
static ngAcceptInputType_multiple: BooleanInput;
static ɵcmp: i0.ɵɵComponentDeclaration<MatSelectionList, "mat-selection-list", ["matSelectionList"], { "disableRipple": "disableRipple"; "tabIndex": "tabIndex"; "color": "color"; "compareWith": "compareWith"; "disabled": "disabled"; "multiple": "multiple"; }, { "selectionChange": "selectionChange"; }, ["options"], ["*"]>;
static ɵfac: i0.ɵɵFactoryDeclaration<MatSelectionList, [null, { attribute: "tabindex"; }, null, null]>;
static ɵcmp: i0.ɵɵComponentDeclaration<MatSelectionList, "mat-selection-list", ["matSelectionList"], { "disableRipple": "disableRipple"; "color": "color"; "compareWith": "compareWith"; "disabled": "disabled"; "multiple": "multiple"; }, { "selectionChange": "selectionChange"; }, ["options"], ["*"]>;
static ɵfac: i0.ɵɵFactoryDeclaration<MatSelectionList, never>;
}

export declare class MatSelectionListChange {
option: MatListOption;
options: MatListOption[];
source: MatSelectionList;
constructor(
source: MatSelectionList,
option: MatListOption,
options: MatListOption[]);
}