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