Skip to content

Commit 97c6ff2

Browse files
committed
main - febc0eb Add a null check to autocomplete options (#30734)
1 parent 2146f51 commit 97c6ff2

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

fesm2022/autocomplete.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ class MatAutocomplete {
206206
}
207207
/** Panel should hide itself when the option list is empty. */
208208
_setVisibility() {
209-
this.showPanel = !!this.options.length;
209+
this.showPanel = !!this.options?.length;
210210
this._changeDetectorRef.markForCheck();
211211
}
212212
/** Emits the `select` event. */
@@ -756,10 +756,10 @@ class MatAutocompleteTrigger {
756756
subscriber.next();
757757
}, { injector: this._environmentInjector });
758758
});
759-
const optionChanges = this.autocomplete.options.changes.pipe(tap(() => this._positionStrategy.reapplyLastPosition()),
759+
const optionChanges = this.autocomplete.options?.changes.pipe(tap(() => this._positionStrategy.reapplyLastPosition()),
760760
// Defer emitting to the stream until the next tick, because changing
761761
// bindings in here will cause "changed after checked" errors.
762-
delay(0));
762+
delay(0)) ?? of();
763763
// When the options are initially rendered, and when the option list changes...
764764
return (merge(initialRender, optionChanges)
765765
.pipe(

fesm2022/autocomplete.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)