Repository navigation
Description
🐞 Bug report
- Relative urls are not working as expected for empty paths when navigate between parent-child routes in the lazy loaded modules
- Relative urls are not working as expected for empty paths when navigate between parent-child routes in the eager loaded modules as well
Affected Package
The issue is caused by package @angular/router
Description
- Navigate to child-component (./child1-component)
- Navigate back to parent (../)
- Navigate to child-component again (./child1-component).
- But it tries to navigate to "//child1-component" & throws an error
Routes in app module (forRoot)
const routes: Routes = [
{
path: '',
loadChildren: 'app/lazy/lazy.module#LazyModule'
},
];
Lazy loaded module routes (forChild)
const routes: Routes = [
{
path: '',
component: LazyComponent,
children: [
{
path: 'child1-component',
component: BComponent
},
{
path: 'child2-component',
component: CComponent
},
]
}
];
🔬 Minimal Reproduction
Lazy Loading: https://stackblitz.com/edit/relative-link-lazy-loading
Eager Loading: https://stackblitz.com/edit/relative-link-eager-loading
🔥 Exception or Error
Error: Uncaught (in promise): SecurityError: Failed to execute 'pushState' on 'History': A history state object with URL 'https://%28child1-component%29/' cannot be created in a document with origin 'https://relative-link-lazy-loading.stackblitz.io' and URL 'https://relative-link-lazy-loading.stackblitz.io/'.
🌍 Your Environment
Angular CLI: 7.3.3
Node: 10.8.0
OS: darwin x64
Angular: 7.2.15
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router
**Angular Version:**
@angular-devkit/architect 0.13.9
@angular-devkit/build-angular 0.13.9
@angular-devkit/build-optimizer 0.13.9
@angular-devkit/build-webpack 0.13.9
@angular-devkit/core 7.3.9
@angular-devkit/schematics 7.3.3
@angular/cdk 7.3.7
@angular/cli 7.3.3
@angular/material 7.3.7
Anything else relevant?
No
UPDATE:
It is not specific to lazy loading. I can reproduce the same empty path issue with eager loading as well
Activity
[-]Relative link routing in the lazyloaded modules with empty paths is not working[/-][+]Relative link routing in the lazyloaded modules with empty paths are not working[/+][-]Relative link routing in the lazyloaded modules with empty paths are not working[/-][+]Relative link routing in a lazyloaded module with empty paths are not working[/+][-]Relative link routing in a lazyloaded module with empty paths are not working[/-][+]Relative link routing with empty paths are not working[/+]kioviensis commentedon May 18, 2019
After debugging, I found out that UrlTree is different
Before (first attempt to navigate to ./child1-component
After (other attempts to navigate to ./child1-component
So, after second navigation, we got changed UrlTree and +1 nested UrlSegmentGroup
That is a reason, why it trapped into the third condition of
serializeSegmentatscott commentedon May 29, 2020
Closing as duplicate of #35687
Related/duplicates:
#13011
#18059
#19290
#35687
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.