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

Method close

src/material/dialog/dialog-ref.ts:123–156  ·  view source on GitHub ↗

* Close the dialog. * @param dialogResult Optional result to return to the dialog opener.

(dialogResult?: R)

Source from the content-addressed store, hash-verified

121 * @param dialogResult Optional result to return to the dialog opener.
122 */
123 close(dialogResult?: R): void {
124 const closePredicate = this._config.closePredicate;
125
126 if (closePredicate && !closePredicate(dialogResult, this._config, this.componentInstance)) {
127 return;
128 }
129
130 this._result = dialogResult;
131
132 // Transition the backdrop in parallel to the dialog.
133 this._containerInstance._animationStateChanged
134 .pipe(
135 filter(event => event.state === 'closing'),
136 take(1),
137 )
138 .subscribe(event => {
139 this._beforeClosed.next(dialogResult);
140 this._beforeClosed.complete();
141 this._ref.overlayRef.detachBackdrop();
142
143 // The logic that disposes of the overlay depends on the exit animation completing, however
144 // it isn't guaranteed if the parent view is destroyed while it's running. Add a fallback
145 // timeout which will clean everything up if the animation hasn't fired within the specified
146 // amount of time plus 100ms. We don't need to run this outside the NgZone, because for the
147 // vast majority of cases the timeout will have been cleared before it has the chance to fire.
148 this._closeFallbackTimeout = setTimeout(
149 () => this._finishDialogClose(),
150 event.totalTime + 100,
151 );
152 });
153
154 this._state = MatDialogState.CLOSING;
155 this._containerInstance._startExitAnimation();
156 }
157
158 /**
159 * Gets an observable that is notified when the dialog is finished opening.

Callers 12

_finishDialogCloseMethod · 0.45
_closeDialogViaFunction · 0.45
_closeDialogsMethod · 0.45
dialog.spec.tsFile · 0.45
_handleUserSelectionMethod · 0.45
openedFunction · 0.45
ngOnDestroyFunction · 0.45
_openOverlayFunction · 0.45
datepicker.spec.tsFile · 0.45
_applySelectionMethod · 0.45

Calls 4

_finishDialogCloseMethod · 0.95
detachBackdropMethod · 0.80
nextMethod · 0.45
_startExitAnimationMethod · 0.45

Tested by

no test coverage detected