There was an error while loading. Please reload this page.
1 parent 8a8a941 commit 7e31a91Copy full SHA for 7e31a91
1 file changed
packages/angular/src/lib/cdk/dialog/native-modal-ref.ts
@@ -165,7 +165,8 @@ export class NativeModalRef {
165
166
// Core tears the view down right after this callback returns, so the listener has to be
167
// attached synchronously, before any await.
168
- const modalView = this.modalViewRef?.firstNativeLikeView;
+ // Prefer the presented wrapper; HMR may replace the first root.
169
+ const modalView = this.modalView ?? this.modalViewRef?.firstNativeLikeView;
170
const whenUnloaded = modalView?.isLoaded ? new Promise<void>((resolve) => modalView.once(View.unloadedEvent, () => resolve())) : Promise.resolve();
171
172
await this.location?._closeModalNavigation();
0 commit comments