question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: Nested ion-router-outlet renders as page instead of sub-component

See original GitHub issue

Bug Report

Ionic version:

[x] 4.x

Current behavior:

Currently using a nested ion-router-outlet in one of my components:

<h2 id="dashboard-header">Dashboard</h2>
<ion-router-outlet></ion-router-outlet>

With the following router configuration:

const routes: Routes = [
  { path: '', redirectTo: 'login', pathMatch: 'full' },
  { path: 'login', loadChildren: './login/login.module#LoginModule' },
  { path: 'register', loadChildren: './register/register.module#RegisterModule' },
  { 
    path: 'dashboard', 
    component: Dashboard,
    canActivate: [AuthGuard],
    canActivateChild: [AuthGuard],
    children: [
      { path: 'submit', loadChildren: './submission/submission.module#SubmissionModule' }
    ]
  }
];

When hitting the /dashboard/submit endpoint the submission component takes the whole screen, appearing over the header. Looking into the styling, I found the following styles for ion-router-outlet:

:host {
left: 0;
right: 0;
top: 0;
bottom: 0;
position: absolute;
contain: layout size style;
overflow: hidden;
z-index: 0;
}

and the submission component:

.ion-page {
left: 0;
right: 0;
top: 0;
bottom: 0;
display: -webkit-box;
display: flex;
position: absolute;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
flex-direction: column;
-webkit-box-pack: justify;
justify-content: space-between;
contain: layout size style;
overflow: hidden;
z-index: 0;
}

The submission component does not have the IonicPage annotation. Why is this styling getting applied?

Expected behavior:

The ion-router-outlet and the submission component should not have absolute positioning.

Steps to reproduce:

-Pull the following repo -Checkout the ion-router-issue tag: git checkout ion-router-issue -cd frontend -ionic serve -Go to /dashboard/submit

The Dashboard header should appear.

Ionic info:

Ionic: Ionic CLI : 5.4.16 (/usr/local/lib/node_modules/ionic) Ionic Framework : @ionic/angular 5.0.0 @angular-devkit/build-angular : 0.803.25 @angular-devkit/schematics : 8.3.25 @angular/cli : 8.3.25 @ionic/angular-toolkit : 2.1.2 Capacitor: Capacitor CLI : 1.5.0 @capacitor/core : 1.5.0 Utility: cordova-res : 0.9.0 native-run : 0.3.0 System: NodeJS : v13.5.0 (/usr/local/Cellar/node/13.5.0/bin/node) npm : 6.13.4 OS : macOS Catalina

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
liamdebeasicommented, Apr 8, 2020

@guzmanoj Thanks! I am going to close this as a duplicate of https://github.com/ionic-team/ionic/issues/18197. (It is a different scenario, but the underlying issue appears to be the same).

1reaction
bcaton85commented, Mar 20, 2020

Hi Liam. That repo has been progressed past that commit since i posted this. I’ve added a ion-router-issue tag to the commit where i was seeing the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ionic Angular - Nested ion-router-outlet ... - Stack Overflow
I'm using a nested ion-router-outlet in order to render routes as a subcomponent, rather than take the entire page.
Read more >
Ionic Angular - Nested ion-router-outlet rendering as page ...
Coding example for the question Ionic Angular - Nested ion-router-outlet rendering as page instead of sub-component-angular.js.
Read more >
Ion-router-outlet not working on sub-pages
I've been trying to display the contents of a page on a sub ion-router-outlet but so far to no avail.
Read more >
Angular 10|9|8 Nested Routing with Multiple RouterOutlet ...
What we are going to create? · 1) Three levels of Nested Routing. · 2) Separate RouterModules and Component Modules. · 3) Handling...
Read more >
Angular Router: Child Routes, Auxiliary Routes, Master Detail
but if we try to type the URL in the browser address bar to access directly for example /lessons , we get a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found