MCPcopy Index your code
hub / github.com/angular/components / _resetOptions

Method _resetOptions

src/material/select/select.ts:1197–1220  ·  view source on GitHub ↗

Drops current option subscriptions and IDs and resets from scratch.

()

Source from the content-addressed store, hash-verified

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