Skip to content

Commit 823d471

Browse files
crisbetojelbourn
authored andcommitted
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.
1 parent 25e67e6 commit 823d471

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/lib/bottom-sheet/bottom-sheet-ref.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,13 @@ export class MatBottomSheetRef<T = any, R = any> {
5858
});
5959

6060
// Dispose overlay when closing animation is complete
61-
containerInstance._animationStateChanged.pipe(
62-
filter(event => event.phaseName === 'done' && event.toState === 'hidden'),
63-
take(1)
64-
)
65-
.subscribe(() => {
66-
this._overlayRef.dispose();
61+
containerInstance._animationStateChanged
62+
.pipe(filter(event => event.phaseName === 'done' && event.toState === 'hidden'), take(1))
63+
.subscribe(() => {
64+
_overlayRef.dispose();
65+
});
66+
67+
_overlayRef.detachments().pipe(take(1)).subscribe(() => {
6768
this._afterDismissed.next(this._result);
6869
this._afterDismissed.complete();
6970
});

0 commit comments

Comments
 (0)