diff --git a/core/src/utils/overlays.ts b/core/src/utils/overlays.ts index fa9012671a4..85847e6372a 100644 --- a/core/src/utils/overlays.ts +++ b/core/src/utils/overlays.ts @@ -138,6 +138,8 @@ const trapKeyboardFocus = (ev: Event, doc: Document) => { * wrapper element as the traps live outside of the wrapper. */ const overlayRoot = getElementRoot(lastOverlay); + if (!overlayRoot.contains(target)) { return; } + const overlayWrapper = overlayRoot.querySelector('.ion-overlay-wrapper'); if (!overlayWrapper) { return; }