Skip to content

bug: Navigation between pages from different nested IonRouterOutlet's breaks UI due to outlets overlap #20219

Closed
@alekseykarpenko

Description

@alekseykarpenko

Bug Report

Ionic version:

[x] 4.11.8 (latest)

Current behavior:
When trying to navigate between two pages from different IonRouterOutlets UI is flickering and breaks, as non active outlet is on the top of others, making all visible UI elements unreachable.

Expected behavior:
Navigation between two pages from different nested IonRouterOutlet's should be possible. Router outlets shouldn't overlap each other, correctly determining which of them is active now (on the top of others).

Steps to reproduce:

Basically, what I'm trying to do is navigation between two pages Home (/home) and List (/list), both of them are inside global IonRouterOutlet, and both have inner IonRouterOutet for their own nested routes, as described in Docs. And here is a deal: I want to navigate directly from nested route of Home (e.g. /home/welcome) to the nested route of the List (e.g. /list/:id) with correct page transition. And it even works... but only for the first time. Then there are 3 different outlets in DOM overlapping each other, two with z-index: 0 (one of them is needed), and another (incorrect) with z-index:101, so UI is blocked with transparent alien outlet.

Related code:

https://gist.github.com/alekseykarpenko/6e5c71f915cf53eeee896e24ab1ee562/7af928cff5ee6a6553d4fa899d22f5874cc9cb42

Other information:

❗️ Looks like this is strictly related to #18197, #18823, #18845 (all of those Angular issues have been opened since last summer).
The quick workaround for me here was moving List's nested routes into parent IonRouterOutlet:

<IonApp>
  <IonReactRouter>
      <IonRouterOutlet>
        {/*<Route path="/list" component={ListPage}/>*/}
        <Route path="/list" component={List} exact={true}/>
        <Route path="/list/:id" component={Item}/>
        <Route path="/home" component={HomePage}/>
        <Route path="/" render={() => <Redirect to="/home"/> } exact={true} />
      </IonRouterOutlet>
  </IonReactRouter>
</IonApp>

https://gist.github.com/alekseykarpenko/6e5c71f915cf53eeee896e24ab1ee562/7af928cff5ee6a6553d4fa899d22f5874cc9cb42

But that's not a real gold bullet, I want it back 😢 Actually, I have two reasons for that: 1) Use all power of React Router nested routes; and 2) Place Home inside Tabs View while List will not be there and add Side Menu to both of them within the global IonRouterOutlet.

Thoughts on fixing this
Even while both pages are in different nested outlets, they have same global outlet. Looks like navigation goes in right way, but outlet controller can't determine current active outlet, giving incorrect z-index.

Ionic info:

Ionic:

   Ionic CLI       : 5.4.11 (/Users/ak/.nvm/versions/node/v10.16.3/lib/node_modules/ionic)
   Ionic Framework : @ionic/react 4.11.8

Utility:

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

System:

   NodeJS : v10.16.3 (/Users/ak/.nvm/versions/node/v10.16.3/bin/node)
   npm    : 6.9.0
   OS     : macOS Catalina

Best regards and thanks for all that you do 💪 Keep em going.

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