Skip to content

fix(loading): use the same z-index base as the other overlays - #31796

Open
ngocanhnckh wants to merge 1 commit into
ionic-team:mainfrom
ngocanhnckh:fix/loading-z-index-base
Open

ngocanhnckh wants to merge 1 commit into
ionic-team:mainfrom
ngocanhnckh:fix/loading-z-index-base

Conversation

@ngocanhnckh

Copy link
Copy Markdown

Issue number: resolves #30029


What is the current behavior?

ion-loading sets its z-index from a base of 40000 plus the overlay counter. ion-alert, ion-action-sheet, ion-modal and ion-popover use 20000. A loading indicator therefore always paints over those overlays, even when they are presented after it. An alert opened while a loading indicator is showing is hidden behind it and its buttons cannot be clicked.

Measured in the core test app (loading presented, then alert): loading z-index: 40002, alert z-index: 20004.

What is the new behavior?

  • ion-loading uses a base of 20000, the same as the other overlays, so stacking follows the order overlays were presented in. This is the direction agreed in the issue. ion-toast keeps its higher base.
  • Added a spec test that presents a loading and then an alert and checks the alert's z-index is higher. It fails without the fix and passes with it.
  • After the fix: loading z-index: 20002, alert z-index: 20004.

Does this introduce a breaking change?

  • Yes
  • No

An overlay presented after a loading indicator now stacks above it, and a loading presented while a modal/alert/popover is open now stacks above that, matching present order.

Other information

Tested with a local test page (loading then alert) at 375px and 1280px, light and dark. Commands: npx stencil test --spec -- src/utils src/components/{loading,alert,action-sheet,modal,popover,toast} (426 passed), eslint and prettier on the touched files. Playwright e2e was not run locally (browser version mismatch, screenshot tests need Docker).

The red boxes in the before shots mark the broken part.

Width Before After
375px, light Before, 375px light After, 375px light
1280px, light Before, 1280px light After, 1280px light
375px, dark Before, 375px dark After, 375px dark
1280px, dark Before, 1280px dark After, 1280px dark

I also checked this with renderlint, an open-source CLI I maintain that renders pages in a headless browser and reports layout defects. Before the change it flags the alert at 375px as sitting under the loading overlay (focus-obscured); after it, it reports nothing. If it would be useful, I'm happy to open a follow-up PR that runs it on the test pages in CI; no pressure either way.

The loading overlay used a z-index base of 40000 while alert, action sheet,
modal and popover use 20000, so a loading indicator always covered an
overlay presented after it. With the same base, the z-index follows the
order the overlays were presented in.

Closes ionic-team#30029
@ngocanhnckh
ngocanhnckh requested a review from a team as a code owner November 20, 2026 04:38
@ngocanhnckh
ngocanhnckh requested a review from thetaPC November 20, 2026 04:38
@vercel

vercel Bot commented Nov 20, 2026

Copy link
Copy Markdown

@ngocanhnckh 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 Nov 20, 2026

This branch has not been deployed

No deployments
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: Alerts are always displayed behind loading indicators making them inaccessible

1 participant