Skip to content

Commit 37598cf

Browse files
atscottalxhub
authored andcommitted
refactor(router): Adjust push/replace behavior to account for navigation API timing issues
There is a bug (?) in all browsers where the timing of the entry change is delayed when a navigation is initiated by a click on a link via user interaction. In this case, we need to ensure we do a 'push' navigation rather than a 'replace'. Programatically doing element.click() does not reproduce this behavior, so adding a test for this is difficult (would require webdriver).
1 parent 5fa4075 commit 37598cf

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

packages/router/src/statemanager/navigation_state_manager.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,13 @@ export class NavigationStateManager extends StateManager {
221221
};
222222

223223
const info: NavigationInfo = {ɵrouterInfo: {intercept: true}};
224+
// https://issues.chromium.org/issues/460137775 - Bug in all browsers where URL might actually not be updated
225+
// by the time we get here. replaceUrl was set to true in the Router when navigating to sync with the browser
226+
// because it assumes the URL is already committed. In this scenario, we need to go back to 'push' behavior
227+
// because it was not yet been committed and we should not replace the current entry.
228+
if (!this.navigation.transition && this.currentNavigation.navigationEvent) {
229+
transition.extras.replaceUrl = false;
230+
}
224231

225232
// Determine if this should be a 'push' or 'replace' history operation.
226233
const history =

0 commit comments

Comments
 (0)