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

Method _exitAndDetach

src/material/select/select.ts:771–800  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

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

Callers 1

closeMethod · 0.95

Calls 3

_detachOverlayMethod · 0.95
listenMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected