ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

bug: ionic angular does not fully support relative and auxiliary routes

Open lincolnthree opened this issue 5 years ago • 7 comments

Bug Report

Ionic version:

[x] 4.x

Current behavior: routerLink stops working after navigating to and subsequently deactivating a named/secondary outlet route.

Expected behavior:

Router Links should continue to work even after the outlet/route they refer to has been navigated to and subsequently deactivated.

Steps to reproduce:

  1. Clone sample app, cd into folder, npm i, ionic serve...
  2. Open the application http://localhost:8100
  3. Click "Metagame" on the app menu
  4. Click "Works once"
  5. Click the (X) at the top of the detail outlet to close it (or click "Metagame in the menu again)
  6. Click "Works once" --- Nothing happens --- we should re-open the detail/secondary outlet here but it does not.
  7. Click "Works every time" -- the outlet opens like it should have. But we should not need to specify fully qualified URLs to routerLink, that's horrifyingly leaky and a maintenance nightmare

Now. In app.component.html, replace <ion-router-outlet main class="app-main"></ion-router-outlet> with <router-outlet main class="app-main"></router-outlet>

Repeat steps 1-5: The outlet opens as expected.

This is a blocking bug in ion-router-outlet. The only workaround is to hardcode fully qualified router URLs in the entire application, rather than properly targeting named router outlets directly via their proper relative URL. which would immediately break everything as soon as a single route in the middle of the hierarchy is changed.

Related code: https://github.com/TopDecked/ionic-router-outlet-bug

Other information:

This seems related to: https://github.com/ionic-team/ionic/issues/16534 https://github.com/ionic-team/ionic/issues/18197 https://github.com/ionic-team/ionic/issues/18823 https://github.com/ionic-team/ionic-v3/issues/713 (this should not have been moved to v3 repo...)

Ionic info:

Lincolns-MacBook-Pro-2:topdecked-named-router-bug lincoln$ ionic info

Ionic:

   Ionic CLI                     : 5.2.1 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.6.2
   @angular-devkit/build-angular : 0.800.3
   @angular-devkit/schematics    : 7.3.1
   @angular/cli                  : 8.0.3
   @ionic/angular-toolkit        : 1.5.1

Cordova:

   Cordova CLI       : 8.1.2 ([email protected])
   Cordova Platforms : not available
   Cordova Plugins   : not available

Utility:

   cordova-res : not installed
   native-run  : 0.2.7 (update available: 0.2.8)

System:

   Android SDK Tools : 26.1.1 (/usr/local/share/android-sdk)
   ios-deploy        : 1.9.4
   NodeJS            : v12.3.1 (/usr/local/Cellar/node/12.3.1/bin/node)
   npm               : 6.10.1
   OS                : macOS Mojave
   Xcode             : Xcode 10.2.1 Build version 10E1001

lincolnthree avatar Jul 19 '19 18:07 lincolnthree

yeah same here not working

LakshanKarunathilake avatar Jul 21 '19 16:07 LakshanKarunathilake

do i think the same in ionic 4.6.2 update angular route are not working .. i just start a new project with ionic 4.6.2 side menu and build with cordova@8 and when i install in mobile .. on the first screen mean home page i press the hardware back button the home page is getting refresh and from menu if we login to list menu and press the hardward back button its going to home page . it should not have to go to home page because in [routerDirection]="'root'"

please fix the issue ....

thanks in advance

pioneersingh321 avatar Jul 22 '19 05:07 pioneersingh321

It seems it's a duplicate of #18197, which is locked... so I can't +1 it. Any progress on this? This seems like a major bug. Basically the routing isn't working...

DmitryEfimenko avatar Mar 03 '20 08:03 DmitryEfimenko

+1

wanting615 avatar Mar 20 '20 07:03 wanting615

@mhartington (or anybody from Ionic @adamdbradley @brandyscarney) do you mind providing an update?

DmitryEfimenko avatar Apr 02 '20 06:04 DmitryEfimenko

Milestone 💪

lincolnthree avatar Sep 03 '20 18:09 lincolnthree

Hey everyone,

I had a chance to look into this and see what was going on. The problem here is that the routing integration in Ionic Angular does not fully support relative and auxiliary routes.

Taking the repo in https://github.com/ionic-team/ionic-framework/issues/18845#issue-470469725 as an example, what was happening after clicking "Metagame" the second time was that we could not determine the correct route. So instead of going to the auxiliary route, Angular was trying to navigate to the /metagame route. Since we were already on the /metagame route, nothing happened giving the appearance that the navigation was not working.

Properly supporting this will require a significant refactor of our current router setup. If we do this refactor, we would like to do it during a major version change. I am going to remove this issue from the current milestone for now, but we will revisit this as we get closer to planning the next major version of Ionic Framework.

Thanks!

liamdebeasi avatar Dec 02 '20 20:12 liamdebeasi