You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Relative navigation to siblings broken with empty/component-less routes #19290
[ ] Regression (a behavior that used to work and stopped working in a new release)
[x ] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior
Relative navigation with '../x' or '../../x' fails when crossing an empty/componentless/lazy-loaded route.
Minimal reproduction of the problem with instructions
I created a minimalistic plunkr, that covers this issue. It's not only related to lazy loaded, but also to componentless empty routes. The behavior also depends on the existence of deeper child routes, which 'toggles' whether ../x or ../../x router-links will work or fail.
Tested with Angular Version 4.3.6 and 4.4.3 (which is used in plunkr at the time of this writing).
Just follow the instructions in the plunkr and watch the console.
The plunkr covers another issue with using multiple '..' commands for navigation, e.g. [routerLink]="['..','..','home']"
which will result in urls containing double dots, like /a/../home
Expected behavior
It works in a consistent and expected way:
empty routes are treated as non-existent, when navigating with '..'-commands/paths
the existence of activated child routes does not change behavior
What is the motivation / use case for changing the behavior?
The current implementation is very confusing, and impossible to use correctly without analyzing the activated routes children, as their mere existence change the behavior (see plunkr). This makes a correct static configuration of the links impossible.
I just ran into this as well. The relative navigation kept trying to add the sibling as a sub-segment of the other sibling. Like, /sibling-a/(sibling-b). Adding the prefix helped.
@bennadel Hi Ben, you mentioned that adding the prefix helped, did it fix the issue with lazy loading and you were able to navigate from ../child-1 to ../child-2 instead of ../child-1/child-2 ? What exactly does adding the prefix mean sorry ? Thanks :)
@VamsiVempati sorry, I have not tried anything with lazy-loading yet. Regarding "prefix", I think what I meant was that I made them all absolute paths, rather than relative paths.
relativeLinkResolution: 'corrected' is the fix for the issue described here. From the B2 component, [../b1] is the correct relative link, even when there is a child route present. It works in both cases. I've opened #37355 to make this option the default.
Activity
tiwieso commentedon Sep 21, 2017
I updated the plunkr to show a related issue with auxiliary routes affecting the navigation in a different way.
bennadel commentedon Oct 5, 2017
I just ran into this as well. The relative navigation kept trying to add the sibling as a sub-segment of the other sibling. Like,
/sibling-a/(sibling-b). Adding the prefix helped.VamsiVempati commentedon Nov 8, 2017
@bennadel Hi Ben, you mentioned that adding the prefix helped, did it fix the issue with lazy loading and you were able to navigate from ../child-1 to ../child-2 instead of ../child-1/child-2 ? What exactly does adding the prefix mean sorry ? Thanks :)
bennadel commentedon Nov 8, 2017
@VamsiVempati sorry, I have not tried anything with lazy-loading yet. Regarding "prefix", I think what I meant was that I made them all absolute paths, rather than relative paths.
bennadel commentedon Nov 8, 2017
@VamsiVempati I think that maybe I was getting this issue and this other issue - #14662 - confused when I was talking about "prefix".
haskelcurry commentedon Dec 20, 2019
Hi, any updates on this? Having the empty route is a very common case
atscott commentedon May 27, 2020
Confirmed in Angular 9 as well: https://stackblitz.com/edit/angular-ivy-rmryyb?file=src%2Fapp%2Fapp.module.ts
Similar issues: #12976, #13011
atscott commentedon May 29, 2020
relativeLinkResolution: 'corrected'is the fix for the issue described here. From the B2 component,[../b1]is the correct relative link, even when there is a child route present. It works in both cases. I've opened #37355 to make this option the default.angular-automatic-lock-bot commentedon Jun 30, 2020
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.