* Dismisses the bottom sheet. * @param result Data to be passed back to the bottom sheet opener.
(result?: R)
| 102 | * @param result Data to be passed back to the bottom sheet opener. |
| 103 | */ |
| 104 | dismiss(result?: R): void { |
| 105 | if (!this.containerInstance) { |
| 106 | return; |
| 107 | } |
| 108 | |
| 109 | // Transition the backdrop in parallel to the bottom sheet. |
| 110 | this.containerInstance._animationStateChanged |
| 111 | .pipe( |
| 112 | filter(event => event.phase === 'start'), |
| 113 | take(1), |
| 114 | ) |
| 115 | .subscribe(() => { |
| 116 | // The logic that disposes of the overlay depends on the exit animation completing, however |
| 117 | // it isn't guaranteed if the parent view is destroyed while it's running. Add a fallback |
| 118 | // timeout which will clean everything up if the animation hasn't fired within the specified |
| 119 | // amount of time plus 100ms. We don't need to run this outside the NgZone, because for the |
| 120 | // vast majority of cases the timeout will have been cleared before it has fired. |
| 121 | this._closeFallbackTimeout = setTimeout(() => this._ref.close(this._result), 500); |
| 122 | this._ref.overlayRef.detachBackdrop(); |
| 123 | }); |
| 124 | |
| 125 | this._result = result; |
| 126 | this.containerInstance.exit(); |
| 127 | this.containerInstance = null!; |
| 128 | } |
| 129 | |
| 130 | /** Gets an observable that is notified when the bottom sheet is finished closing. */ |
| 131 | afterDismissed(): Observable<R | undefined> { |
no test coverage detected