Skip to content

Commit ea2b389

Browse files
committed
fix(modal): dismiss top-most overlay when multiple IDs match
1 parent 8573bf8 commit ea2b389

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

core/src/utils/overlays.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,9 @@ export const getPresentedOverlay = (
473473
id?: string
474474
): HTMLIonOverlayElement | undefined => {
475475
const overlays = getPresentedOverlays(doc, overlayTag);
476-
return id === undefined ? overlays[overlays.length - 1] : overlays.find((o) => o.id === id);
476+
// If no id is provided, return the last presented overlay
477+
// Otherwise, return the last overlay with the given id
478+
return (id === undefined ? overlays : overlays.filter((o: HTMLIonOverlayElement) => o.id === id)).slice(-1)[0];
477479
};
478480

479481
/**

0 commit comments

Comments
 (0)