Skip to content

Commit 60650a3

Browse files
committed
fix a bug with null options
1 parent d69de97 commit 60650a3

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/material/autocomplete/autocomplete-trigger.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -625,12 +625,12 @@ export class MatAutocompleteTrigger
625625
{injector: this._environmentInjector},
626626
);
627627
});
628-
const optionChanges = this.autocomplete.options.changes.pipe(
628+
const optionChanges = this.autocomplete.options?.changes.pipe(
629629
tap(() => this._positionStrategy.reapplyLastPosition()),
630630
// Defer emitting to the stream until the next tick, because changing
631631
// bindings in here will cause "changed after checked" errors.
632632
delay(0),
633-
);
633+
) ?? observableOf();
634634

635635
// When the options are initially rendered, and when the option list changes...
636636
return (

src/material/autocomplete/autocomplete.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ export class MatAutocomplete implements AfterContentInit, OnDestroy {
307307

308308
/** Panel should hide itself when the option list is empty. */
309309
_setVisibility() {
310-
this.showPanel = !!this.options.length;
310+
this.showPanel = !!this.options?.length;
311311
this._changeDetectorRef.markForCheck();
312312
}
313313

0 commit comments

Comments
 (0)