Skip to content

Commit 7e31a91

Browse files
committed
fix(angular): await unloaded on the presented modal wrapper during dismissal
1 parent 8a8a941 commit 7e31a91

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

packages/angular/src/lib/cdk/dialog/native-modal-ref.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ export class NativeModalRef {
165165

166166
// Core tears the view down right after this callback returns, so the listener has to be
167167
// attached synchronously, before any await.
168-
const modalView = this.modalViewRef?.firstNativeLikeView;
168+
// Prefer the presented wrapper; HMR may replace the first root.
169+
const modalView = this.modalView ?? this.modalViewRef?.firstNativeLikeView;
169170
const whenUnloaded = modalView?.isLoaded ? new Promise<void>((resolve) => modalView.once(View.unloadedEvent, () => resolve())) : Promise.resolve();
170171

171172
await this.location?._closeModalNavigation();

0 commit comments

Comments
 (0)