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

Method _exitAndDetach

src/material/select/select.ts:773–802  ·  view source on GitHub ↗

Triggers the exit animation and detaches the overlay at the end.

()

Source from the content-addressed store, hash-verified

771
772 /** Triggers the exit animation and detaches the overlay at the end. */
773 private _exitAndDetach() {
774 if (this._animationsDisabled || !this.panel) {
775 this._detachOverlay();
776 return;
777 }
778
779 this._cleanupDetach?.();
780 this._cleanupDetach = () => {
781 cleanupEvent();
782 clearTimeout(exitFallbackTimer);
783 this._cleanupDetach = undefined;
784 };
785
786 const panel: HTMLElement = this.panel.nativeElement;
787 const cleanupEvent = this._renderer.listen(panel, 'animationend', (event: AnimationEvent) => {
788 if (event.animationName === '_mat-select-exit') {
789 this._cleanupDetach?.();
790 this._detachOverlay();
791 }
792 });
793
794 // Since closing the overlay depends on the animation, we have a fallback in case the panel
795 // doesn't animate. This can happen in some internal tests that do `* {animation: none}`.
796 const exitFallbackTimer = setTimeout(() => {
797 this._cleanupDetach?.();
798 this._detachOverlay();
799 }, 200);
800
801 panel.classList.add('mat-select-panel-exit');
802 }
803
804 /** Detaches the current overlay directive. */
805 private _detachOverlay() {

Callers 1

closeMethod · 0.95

Calls 3

_detachOverlayMethod · 0.95
listenMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected