Skip to content

bug: App-wide ion-alert gets covered by page-specific ion-modal #22339

@diegodlh

Description

@diegodlh

Bug Report

Ionic version:

[ ] 4.x
[x] 5.x

Current behavior:

An app-wide alert included in a Ionic React project's App.tsx file is covered by a modal opened by one of the app's pages.

Expected behavior:

The alert should remain on top of everything else.

Steps to reproduce:

  1. Include an IonAlert element as child of the IonApp element in the App.tsx file. I found this to be the easiest way to have an app-wide alert.
  2. Include an IonModal element in the default Home page of the app.
  3. When the app launches, it briefly shows the app-wide alert, but then it gets covered by the Home page's modal. The ion-alert element is still there, but with a z-index smaller than the ion-modal element.

Related code:
See this example app forked from ionic-react-tabs: https://stackblitz.com/edit/ionic-react-tabs-3zz2qa

Other information:

In the app I am developing (which unfortunately I cannot share) the logic to decide whether to show the alert and modal is more complex than a simple true/false, and in this situation a race condition occurs where sometimes the ion-alert element is opened later and ends up with a higher z-index on top, while sometimes the ion-modal opens later and ends up on top instead.

Ionic info:

Ionic:

   Ionic CLI       : 6.11.0 (~/.nvm/versions/node/v12.18.3/lib/node_modules/@ionic/cli)
   Ionic Framework : @ionic/react 5.2.3

Capacitor:

   Capacitor CLI   : 2.2.1
   @capacitor/core : 2.2.1

Utility:

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

System:

   NodeJS : v12.18.3 (~/.nvm/versions/node/v12.18.3/bin/node)
   npm    : 6.14.6
   OS     : Linux 5.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions