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

Method open

src/material/select/select.ts:725–754  ·  view source on GitHub ↗

Opens the overlay panel.

()

Source from the content-addressed store, hash-verified

723
724 /** Opens the overlay panel. */
725 open(): void {
726 if (!this._canOpen()) {
727 return;
728 }
729
730 // It's important that we read this as late as possible, because doing so earlier will
731 // return a different element since it's based on queries in the form field which may
732 // not have run yet. Also this needs to be assigned before we measure the overlay width.
733 if (this._parentFormField) {
734 this._preferredOverlayOrigin = this._parentFormField.getConnectedOverlayOrigin();
735 }
736
737 this._cleanupDetach?.();
738 this._overlayWidth = this._getOverlayWidth(this._preferredOverlayOrigin);
739 this._panelOpen = true;
740 this._overlayDir.positionChange.pipe(take(1)).subscribe(() => {
741 this._changeDetectorRef.detectChanges();
742 this._positioningSettled();
743 });
744 this._overlayDir.attachOverlay();
745 this._keyManager.withHorizontalOrientation(null);
746 this._highlightCorrectOption();
747 this._changeDetectorRef.markForCheck();
748
749 // Required for the MDC form field to pick up when the overlay has been opened.
750 this.stateChanges.next();
751
752 // Simulate the animation event before we moved away from `@angular/animations`.
753 Promise.resolve().then(() => this.openedChange.emit(true));
754 }
755
756 /** Closes the overlay panel and focuses the host element. */
757 close(): void {

Callers 3

toggleMethod · 0.95
_handleClosedKeydownMethod · 0.95
onContainerClickMethod · 0.95

Calls 10

_canOpenMethod · 0.95
_getOverlayWidthMethod · 0.95
_positioningSettledMethod · 0.95
attachOverlayMethod · 0.80
markForCheckMethod · 0.80
resolveMethod · 0.80
nextMethod · 0.45

Tested by

no test coverage detected