diff --git a/aio/src/app/app.component.spec.ts b/aio/src/app/app.component.spec.ts index 7737e04551..de93fe47c0 100644 --- a/aio/src/app/app.component.spec.ts +++ b/aio/src/app/app.component.spec.ts @@ -405,10 +405,12 @@ describe('AppComponent', () => { // Older docs versions have an href it('should navigate when change to a version with a url', async () => { await setupSelectorForTesting(); + locationService.urlSubject.next('new-page?id=1#section-1'); const versionWithUrlIndex = component.docVersions.findIndex(v => !!v.url); const versionWithUrl = component.docVersions[versionWithUrlIndex]; + const versionWithUrlAndPage = `${versionWithUrl.url}new-page?id=1#section-1`; selectElement.triggerEventHandler('change', { option: versionWithUrl, index: versionWithUrlIndex}); - expect(locationService.go).toHaveBeenCalledWith(versionWithUrl.url); + expect(locationService.go).toHaveBeenCalledWith(versionWithUrlAndPage); }); it('should not navigate when change to a version without a url', async () => { diff --git a/aio/src/app/app.component.ts b/aio/src/app/app.component.ts index f4d65b60a8..e0df8fcce1 100644 --- a/aio/src/app/app.component.ts +++ b/aio/src/app/app.component.ts @@ -77,6 +77,8 @@ export class AppComponent implements OnInit { versionInfo: VersionInfo; + private currentUrl: string; + get isOpened() { return this.isSideBySide && this.isSideNavDoc; } get mode() { return this.isSideBySide ? 'side' : 'over'; } @@ -188,6 +190,8 @@ export class AppComponent implements OnInit { this.navigationService.currentNodes, // ...needed to determine `sidenav` state ]).pipe(first()) .subscribe(() => this.updateShell()); + + this.locationService.currentUrl.subscribe(url => this.currentUrl = url); } onDocReady() { @@ -231,7 +235,7 @@ export class AppComponent implements OnInit { onDocVersionChange(versionIndex: number) { const version = this.docVersions[versionIndex]; if (version.url) { - this.locationService.go(version.url); + this.locationService.go(`${version.url}${this.currentUrl}`); } }