MCPcopy Create free account
hub / github.com/angular/components / _resetOptions

Method _resetOptions

src/material/select/select.ts:1199–1222  ·  view source on GitHub ↗

Drops current option subscriptions and IDs and resets from scratch.

()

Source from the content-addressed store, hash-verified

1197
1198 /** Drops current option subscriptions and IDs and resets from scratch. */
1199 private _resetOptions(): void {
1200 const changedOrDestroyed = merge(this.options.changes, this._destroy);
1201
1202 this.optionSelectionChanges.pipe(takeUntil(changedOrDestroyed)).subscribe(event => {
1203 this._onSelect(event.source, event.isUserInput);
1204
1205 if (event.isUserInput && !this.multiple && this._panelOpen) {
1206 this.close();
1207 this.focus();
1208 }
1209 });
1210
1211 // Listen to changes in the internal state of the options and react accordingly.
1212 // Handles cases like the labels of the selected options changing.
1213 merge(...this.options.map(option => option._stateChanges))
1214 .pipe(takeUntil(changedOrDestroyed))
1215 .subscribe(() => {
1216 // `_stateChanges` can fire as a result of a change in the label's DOM value which may
1217 // be the result of an expression changing. We have to use `detectChanges` in order
1218 // to avoid "changed after checked" errors (see #14793).
1219 this._changeDetectorRef.detectChanges();
1220 this.stateChanges.next();
1221 });
1222 }
1223
1224 /** Invoked when an option is clicked. */
1225 private _onSelect(option: MatOption, isUserInput: boolean): void {

Callers 1

ngAfterContentInitMethod · 0.95

Calls 4

_onSelectMethod · 0.95
closeMethod · 0.95
focusMethod · 0.95
nextMethod · 0.45

Tested by

no test coverage detected