fix(bottom-sheet): unable to reopen same bottom sheet after closing via back button (#15520)

Fixes not being able to reopen the same bottom sheet, if the user closed it by pressing back. The issue comes from the fact that we only consider the bottom sheet as closed when its animation completes, however that might not happen if the component is destroyed. The following changes work around the issue by completing the closing sequence on detach, rather than depending on the animation.

Fixes #15510.
This commit is contained in:
Kristiyan Kostadinov
2019-03-28 18:19:29 +01:00
committed by Jeremy Elbourn
parent 25e67e60ab
commit 823d471563
+7 -6
View File
@@ -58,12 +58,13 @@ export class MatBottomSheetRef<T = any, R = any> {
});
// Dispose overlay when closing animation is complete
containerInstance._animationStateChanged.pipe(
filter(event => event.phaseName === 'done' && event.toState === 'hidden'),
take(1)
)
.subscribe(() => {
this._overlayRef.dispose();
containerInstance._animationStateChanged
.pipe(filter(event => event.phaseName === 'done' && event.toState === 'hidden'), take(1))
.subscribe(() => {
_overlayRef.dispose();
});
_overlayRef.detachments().pipe(take(1)).subscribe(() => {
this._afterDismissed.next(this._result);
this._afterDismissed.complete();
});