Skip to content

fix(overlays): ensure overlayIndex is greater than any existing overlay in DOM - #31325

Open
amanmaurya92 wants to merge 1 commit into
ionic-team:mainfrom
amanmaurya92:fix-issue-31247
Open

fix(overlays): ensure overlayIndex is greater than any existing overlay in DOM#31325
amanmaurya92 wants to merge 1 commit into
ionic-team:mainfrom
amanmaurya92:fix-issue-31247

Conversation

@amanmaurya92

Copy link
Copy Markdown

Issue number: resolves #31247


What is the current behavior?

When a dynamically generated overlay (such as an ion-alert triggered by an ion-select with interface="alert") is opened inside an already active overlay (like an ion-modal), it can sometimes be rendered behind the active modal. This is caused by the internal lastOverlayIndex falling out of sync across different module boundaries (common in microfrontends or Angular Standalone Component architectures), causing the newer overlay to receive a lower or equal overlayIndex (and consequently a lower CSS z-index) than the active modal.

What is the new behavior?

  • Modified prepareOverlay in core/src/utils/overlays.ts to actively query the DOM for all existing Ionic overlays.
  • The function now calculates the true maximum overlayIndex currently present in the DOM.
  • New overlays are guaranteed a mathematically higher overlayIndex by assigning the maximum between the module's lastOverlayIndex and the DOM's maxIndex + 1, ensuring the most recently presented overlay is always stacked on top.

Does this introduce a breaking change?

  • Yes
  • No

Other information

This fix natively relies on document.querySelectorAll to serve as a robust Single Source of Truth for the stacking order, which effectively bridges the gap in complex environments where @ionic/core modules might be duplicated or heavily code-split.

@amanmaurya92
amanmaurya92 requested a review from a team as a code owner August 4, 2026 19:16
@amanmaurya92
amanmaurya92 requested a review from BenOsodrac August 4, 2026 19:16
@vercel

vercel Bot commented Aug 4, 2026

Copy link
Copy Markdown

@amanmaurya92 is attempting to deploy a commit to the Ionic Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the package: core @ionic/core package label Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: core @ionic/core package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: ion-alert generated by ion-select is stacked behind active ion-modal

1 participant