Skip to content

Commit 0f7fc80

Browse files
committed
fix(modal): moving mutation observer to the DOM to deal with unknown numbers of grandparents being removed, causing the modal to be removed by nothing to observe it
1 parent 15cac88 commit 0f7fc80

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

core/src/components/modal/modal.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,11 +1183,6 @@ export class Modal implements ComponentInterface, OverlayInterface {
11831183
return;
11841184
}
11851185

1186-
const grandParent = this.cachedOriginalParent.parentNode;
1187-
if (!grandParent) {
1188-
return;
1189-
}
1190-
11911186
this.parentRemovalObserver = new MutationObserver((mutations) => {
11921187
mutations.forEach((mutation) => {
11931188
if (mutation.type === 'childList' && mutation.removedNodes.length > 0) {
@@ -1210,8 +1205,8 @@ export class Modal implements ComponentInterface, OverlayInterface {
12101205
});
12111206
});
12121207

1213-
// Observe with subtree to catch nested removals
1214-
this.parentRemovalObserver.observe(grandParent, {
1208+
// Observe document body with subtree to catch removals at any level
1209+
this.parentRemovalObserver.observe(document.body, {
12151210
childList: true,
12161211
subtree: true,
12171212
});

0 commit comments

Comments
 (0)