Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion packages/angular/common/src/providers/nav-controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import { Location } from '@angular/common';
import { Injectable, Optional } from '@angular/core';
import { NavigationExtras, Router, UrlSerializer, UrlTree, NavigationStart } from '@angular/router';
import {
NavigationExtras,
Router,
UrlSerializer,
UrlTree,
NavigationStart,
NavigationCancel,
NavigationError,
} from '@angular/router';
import type { AnimationBuilder, NavDirection, RouterDirection } from '@ionic/core/components';

import { IonRouterOutlet } from '../directives/navigation/router-outlet';
Expand Down Expand Up @@ -42,6 +50,14 @@ export class NavController {
this.guessDirection = this.guessAnimation = id < this.lastNavId ? 'back' : 'forward';
this.lastNavId = this.guessDirection === 'forward' ? ev.id : id;
}

// Reset explicit direction when navigation is canceled (e.g., guard rejection)
// to prevent stale direction from leaking into the next navigation
if (ev instanceof NavigationCancel || ev instanceof NavigationError) {
this.direction = DEFAULT_DIRECTION;
this.animated = DEFAULT_ANIMATED;
this.animationBuilder = undefined;
}
});
}

Expand Down
Loading