Skip to content

bug: Alerts are always displayed behind loading indicators making them inaccessible #30029

Open

Description

@davidgeary

Prerequisites

Ionic Framework Version

v8.x

Current Behavior

I have a use-case where a loading indicator (ion-loading) is being displayed during a data import process. If the data already exists, an alert (ion-alert) is then displayed, requesting confirmation to overwrite the data. Once the alert is dismissed, the loading indicator continues to be displayed until the process completes.

In this scenario, when the alert is displayed, it is behind the loading indicator's overlay. This means that not only is the alert obscured by the loading indicator, even if its buttons are visible, they cannot be clicked by the end user. (Note that the ion-alert is always created after the ion-loading has been displayed.)

alert-behind-loading

Expected Behavior

Ideally, each overlay-based component would be assigned a z-index higher than any previously-created component, ensuring that they are 'stacked' on-screen in the order that they are created. Indeed, this is how it is described in another - presumably, now out-of-date - issue (see #22339 (comment)).

Steps to Reproduce

  1. Clone the test repo
  2. Run the application with ng serve
  3. Open http://localhost:4200/ in a web browser

The web app will open its home page, displaying first an ion-loading component, then displaying an ion-alert component.

You should see that the alert is behind the loading indicator, preventing it from being seen clearly and stopping its buttons from being clicked.

Code Reproduction URL

https://github.com/davidgeary/zindex-test

Ionic Info

Ionic:

Ionic CLI : 7.2.0 (C:\Users\Xxxxxxxxxxx\AppData\Roaming\nvm\v20.14.0\node_modules@ionic\cli)
Ionic Framework : @ionic/angular 8.4.0
@angular-devkit/build-angular : 18.2.12
@angular-devkit/schematics : 18.2.12
@angular/cli : 18.2.12
@ionic/angular-toolkit : 11.0.1

Capacitor:

Capacitor CLI : 6.2.0
@capacitor/android : not installed
@capacitor/core : 6.2.0
@capacitor/ios : not installed

Utility:

cordova-res : not installed globally
native-run : 2.0.1

System:

NodeJS : v20.14.0 (C:\Program Files\nodejs\node.exe)
npm : 10.7.0
OS : Windows 10

Additional Information

From the code, it appears that the overlay-based components have their z-indexes hard-coded, with each component being assigned a z-index of a 'base' value plus the overlay id of the component. So while components using the same base value will appear stacked in the order they are created, overall the components have an on-screen hierarchy enforced by the base value:

So regardless of which component is created first, ion-loadings will always appear above ion-alerts.

(Also, because the z-index is assigned directly as a style attribute to each individual component, overriding it requires a specific custom CSS class where the z-index property is marked as !important.)

view-source

While there is possibly an argument that ion-toasts should always appear at the top of any stack, I think overlay components should - as a general rule - always appear in the order that they are created. Changing the base value of the ion-loading component to 20000 would accomplish this.

Activity

  1. added
    needs: investigationThis issue is waiting on more investigation from the engineering team.
    and removed on Mar 18, 2026
  2. thetaPC commented on Oct 26, 2026

    @thetaPC
    Contributor

    Thanks for the report, and sorry for the delay.

    Verified on 9.0.9. Each overlay sets its own z-index from a fixed base plus a counter that goes up with every overlay presented. ion-alert, ion-action-sheet, ion-modal and ion-popover share a base of 20000, but ion-loading uses 40000. So a loading indicator paints over any of those, even one presented after it. Focus and the Escape key do follow the order overlays were presented in, which is why the alert has focus but can't be clicked. Your suggestion to put ion-loading on the same base as the others matches what we found.

    Workarounds, both verified on 9.0.9:

    • Dismiss the loading indicator before presenting the alert, and present a new one once the alert is dismissed.
    • Give that one alert a class that raises it above the loading indicator. The !important is needed because the z-index is set as an inline style:
    const alert = await this.alertController.create({
      header: 'Overwrite data?',
      cssClass: 'alert-above-loading',
      buttons: ['Cancel', 'OK'],
    });
    /* global.scss */
    .alert-above-loading {
      z-index: 50000 !important;
    }

    Only use the class on alerts that open over a loading indicator, since a loading indicator presented while that alert is open would end up behind it.

    Tracked as a bug in core.

  3. added
    type: buga confirmed bug report
    and removed
    needs: investigationThis issue is waiting on more investigation from the engineering team.
    on Oct 26, 2026
  4. ngocanhnckh commented on Nov 20, 2026

    @ngocanhnckh

    I'd like to pick this up. As discussed above, ion-loading uses a z-index base of 40000 while alert, action-sheet, modal and popover use 20000, so an alert presented after a loading ends up underneath it. I have a fix that moves loading to the same 20000 base (toast stays at 60000), with a spec test that fails without it. I'll open a PR referencing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions