Skip to content

refactor(material/autocomplete): declare injected properties as nullable #26009

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

Merged
merged 1 commit into from
Nov 29, 2022
Merged
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
12 changes: 7 additions & 5 deletions src/material/autocomplete/autocomplete-trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,13 @@ export abstract class _MatAutocompleteTriggerBase
private _zone: NgZone,
private _changeDetectorRef: ChangeDetectorRef,
@Inject(MAT_AUTOCOMPLETE_SCROLL_STRATEGY) scrollStrategy: any,
@Optional() private _dir: Directionality,
@Optional() @Inject(MAT_FORM_FIELD) @Host() private _formField: MatFormField,
@Optional() private _dir: Directionality | null,
@Optional() @Inject(MAT_FORM_FIELD) @Host() private _formField: MatFormField | null,
@Optional() @Inject(DOCUMENT) private _document: any,
private _viewportRuler: ViewportRuler,
@Optional()
@Inject(MAT_AUTOCOMPLETE_DEFAULT_OPTIONS)
private _defaults?: MatAutocompleteDefaultOptions,
private _defaults?: MatAutocompleteDefaultOptions | null,
) {
this._scrollStrategy = scrollStrategy;
}
Expand Down Expand Up @@ -506,7 +506,9 @@ export abstract class _MatAutocompleteTriggerBase
/** If the label has been manually elevated, return it to its normal state. */
private _resetLabel(): void {
if (this._manuallyFloatingLabel) {
this._formField.floatLabel = 'auto';
if (this._formField) {
this._formField.floatLabel = 'auto';
}
this._manuallyFloatingLabel = false;
}
}
Expand Down Expand Up @@ -679,7 +681,7 @@ export abstract class _MatAutocompleteTriggerBase
positionStrategy: this._getOverlayPosition(),
scrollStrategy: this._scrollStrategy(),
width: this._getPanelWidth(),
direction: this._dir,
direction: this._dir ?? undefined,
panelClass: this._defaults?.overlayPanelClass,
});
}
Expand Down
2 changes: 1 addition & 1 deletion tools/public_api_guard/material/autocomplete.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export class MatAutocompleteTrigger extends _MatAutocompleteTriggerBase {

// @public
export abstract class _MatAutocompleteTriggerBase implements ControlValueAccessor, AfterViewInit, OnChanges, OnDestroy {
constructor(_element: ElementRef<HTMLInputElement>, _overlay: Overlay, _viewContainerRef: ViewContainerRef, _zone: NgZone, _changeDetectorRef: ChangeDetectorRef, scrollStrategy: any, _dir: Directionality, _formField: MatFormField, _document: any, _viewportRuler: ViewportRuler, _defaults?: MatAutocompleteDefaultOptions | undefined);
constructor(_element: ElementRef<HTMLInputElement>, _overlay: Overlay, _viewContainerRef: ViewContainerRef, _zone: NgZone, _changeDetectorRef: ChangeDetectorRef, scrollStrategy: any, _dir: Directionality | null, _formField: MatFormField | null, _document: any, _viewportRuler: ViewportRuler, _defaults?: MatAutocompleteDefaultOptions | null | undefined);
protected abstract _aboveClass: string;
get activeOption(): _MatOptionBase | null;
autocomplete: _MatAutocompleteBase;
Expand Down