Skip to content

Commit 519263a

Browse files
committed
refactor(autocomplete): change deprecated APIs for version 10
Changes the APIs that were marked as deprecated for v10. BREAKING CHANGES: * The `_viewportRuler` parameter in the `MatAutocompleteTrigger` constructor is now required.
1 parent eb218e5 commit 519263a

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

src/material/autocomplete/autocomplete-trigger.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,7 @@ export class MatAutocompleteTrigger implements ControlValueAccessor, AfterViewIn
219219
@Optional() private _dir: Directionality,
220220
@Optional() @Inject(MAT_FORM_FIELD) @Host() private _formField: MatFormField,
221221
@Optional() @Inject(DOCUMENT) private _document: any,
222-
// @breaking-change 8.0.0 Make `_viewportRuler` required.
223-
private _viewportRuler?: ViewportRuler) {
222+
private _viewportRuler: ViewportRuler) {
224223
this._scrollStrategy = scrollStrategy;
225224
}
226225

@@ -642,13 +641,11 @@ export class MatAutocompleteTrigger implements ControlValueAccessor, AfterViewIn
642641
}
643642
});
644643

645-
if (this._viewportRuler) {
646-
this._viewportSubscription = this._viewportRuler.change().subscribe(() => {
647-
if (this.panelOpen && overlayRef) {
648-
overlayRef.updateSize({width: this._getPanelWidth()});
649-
}
650-
});
651-
}
644+
this._viewportSubscription = this._viewportRuler.change().subscribe(() => {
645+
if (this.panelOpen && overlayRef) {
646+
overlayRef.updateSize({width: this._getPanelWidth()});
647+
}
648+
});
652649
} else {
653650
// Update the trigger, panel width and direction, in case anything has changed.
654651
this._positionStrategy.setOrigin(this._getConnectedElement());

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ import {ConstructorChecksUpgradeData, TargetVersion, VersionChanges} from '@angu
1414
* automatically through type checking.
1515
*/
1616
export const constructorChecks: VersionChanges<ConstructorChecksUpgradeData> = {
17+
[TargetVersion.V10]: [
18+
{
19+
pr: 'https://github.com/angular/components/pull/19324',
20+
changes: ['MatAutocompleteTrigger']
21+
}
22+
],
1723
[TargetVersion.V9]: [
1824
{
1925
pr: 'https://github.com/angular/components/pull/17230',

tools/public_api_guard/material/autocomplete.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export declare class MatAutocompleteTrigger implements ControlValueAccessor, Aft
9898
get panelClosingActions(): Observable<MatOptionSelectionChange | null>;
9999
get panelOpen(): boolean;
100100
position: 'auto' | 'above' | 'below';
101-
constructor(_element: ElementRef<HTMLInputElement>, _overlay: Overlay, _viewContainerRef: ViewContainerRef, _zone: NgZone, _changeDetectorRef: ChangeDetectorRef, scrollStrategy: any, _dir: Directionality, _formField: MatFormField, _document: any, _viewportRuler?: ViewportRuler | undefined);
101+
constructor(_element: ElementRef<HTMLInputElement>, _overlay: Overlay, _viewContainerRef: ViewContainerRef, _zone: NgZone, _changeDetectorRef: ChangeDetectorRef, scrollStrategy: any, _dir: Directionality, _formField: MatFormField, _document: any, _viewportRuler: ViewportRuler);
102102
_handleFocus(): void;
103103
_handleInput(event: KeyboardEvent): void;
104104
_handleKeydown(event: KeyboardEvent): void;

0 commit comments

Comments
 (0)