refactor(router): clear pending navigation task in a microtask (#49619)

This commit updates the logic in the Router that keep track of the initial navigation from being a synchronous to a microtask (Promise.resolve) to allow redirects during the initial navigation.

PR Close #49619
This commit is contained in:
Andrew Kushnir
2023-03-28 18:59:00 -07:00
committed by Andrew Scott
parent c024574f46
commit 6bcdb68e69
+5 -1
View File
@@ -742,7 +742,11 @@ export class Router {
// Indicate that the navigation is happening.
const taskId = this.pendingTasks.add();
afterNextNavigation(this, () => this.pendingTasks.remove(taskId));
afterNextNavigation(this, () => {
// Remove pending task in a microtask to allow for cancelled
// initial navigations and redirects within the same task.
Promise.resolve().then(() => this.pendingTasks.remove(taskId));
});
this.navigationTransitions.handleNavigationRequest({
targetPageId,