Repository navigation
Closed
Closed
Copy link
Labels
area: routerfreq3: highopen for contributionsAn issue that is suitable for a community contributor (based on its complexity/scope).router: navigation pipeevents/scheduleNavigation/transitions observablestate: confirmedtype: bug/fix
Milestone
Description
🐞 bug report
Affected Package
The issue is caused by package @angular/router....Is this a regression?
NoDescription
I think there is a small bug - the `history.state` object is getting lost when navigate using back/forward buttons.The fix should be pretty simple- set the restored state into the NavigationExtras parameter in the call of scheduleNavigation in Router.setUpLocationChangeListener() method :
// Navigations coming from Angular router have a navigationId state property. When this
// exists, restore the state.
const state = change.state && change.state.navigationId ? change.state : null;
setTimeout(
() => { this.scheduleNavigation(rawUrlTree, source, state, {replaceUrl: true, state }); }, 0);🔬 Minimal Reproduction
https://stackblitz.com/edit/angular-bupuzn created by @fjauer - just use back/forward after pressing Test button
🔥 Exception or Error
🌍 Your Environment
Angular Version:
Angular CLI: 7.2.1
Node: 10.15.0
OS: win32 x64
Angular: 7.2.0
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.12.1
@angular-devkit/build-angular 0.12.1
@angular-devkit/build-optimizer 0.12.1
@angular-devkit/build-webpack 0.12.1
@angular-devkit/core 7.2.1
@angular-devkit/schematics 7.2.1
@angular/cdk 7.2.1
@angular/cli 7.2.1
@angular/flex-layout 7.0.0-beta.23
@angular/material 7.2.1
@ngtools/webpack 7.2.1
@schematics/angular 7.2.1
@schematics/update 0.12.1
rxjs 6.0.0
typescript 3.2.2
webpack 4.23.1
Anything else relevant?
Reacted by Alessandro Arcangeli, Mark, Owen Buckley, Joe Daley, SGavrilin, Alex Chugaev and dartzki
Metadata
Metadata
Assignees
Labels
area: routerfreq3: highopen for contributionsAn issue that is suitable for a community contributor (based on its complexity/scope).router: navigation pipeevents/scheduleNavigation/transitions observablestate: confirmedtype: bug/fix
Activity
alecvolo commentedon Jan 13, 2019
The workaround is to catch
NavigationStartevent and updateCurrentNavigationobjectHere is the StackBlitz example https://stackblitz.com/edit/angular-xyrmg1 (Should be run in new window)
jasonaden commentedon Jan 15, 2019
Thanks for the issue. Is this something you think you can create a PR for? I would like to get it fixed ASAP, but it will be a little while until this can be pulled in.
alecvolo commentedon Jan 19, 2019
I've created PR #28176
10 remaining items
fix(router): restore 'history.state' object for navigations coming fr…
fixup! fix(router): restore 'history.state' object for navigations co…
fixup! fix(router): restore 'history.state' object for navigations co…
fix(router): restore 'history.state' object for navigations coming fr…
fix(router): restore 'history.state' object for navigations coming fr…
angular-automatic-lock-bot commentedon Oct 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.
fix(router): restore 'history.state' on popstate even if navigationId…
fix(router): restore 'history.state' on popstate even if navigationId…
fix(router): restore 'history.state' on popstate even if navigationId…
fix(router): restore 'history.state' on popstate even if navigationId…