Skip to content

fix(nav-controller): reset direction state when navigation is canceled#30955

Open
ShaneK wants to merge 2 commits intomainfrom
IONIC-85
Open

fix(nav-controller): reset direction state when navigation is canceled#30955
ShaneK wants to merge 2 commits intomainfrom
IONIC-85

Conversation

@ShaneK
Copy link
Member

@ShaneK ShaneK commented Feb 13, 2026

Issue number: resolves internal


What is the current behavior?

When a CanDeactivate guard cancels a back navigation (like when it's initiated by ion-back-button), the NavController’s explicit direction state (back) is never consumed because consumeTransition() is not called for canceled navigations. This stale direction leaks into the next forward navigation, causing it to be incorrectly treated as a back/root navigation.

What is the new behavior?

The NavController now listens for NavigationCancel and NavigationError router events and resets direction, animated, and animationBuilder back to their defaults. This ensures stale state from a canceled navigation does not affect subsequent navigations. The reset puts the NavController into 'auto' mode, which correctly uses guessDirection for the next navigation.

Does this introduce a breaking change?

  • Yes
  • No

Other information

Current dev build:

8.7.18-dev.11771020096.1ca03a6d

@vercel
Copy link

vercel bot commented Feb 13, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ionic-framework Ready Ready Preview, Comment Feb 13, 2026 10:15pm

Request Review

@ShaneK ShaneK marked this pull request as ready for review February 13, 2026 22:09
@ShaneK ShaneK requested a review from a team as a code owner February 13, 2026 22:09
@ShaneK ShaneK requested a review from thetaPC February 13, 2026 22:09
@github-actions github-actions bot added the package: angular @ionic/angular package label Feb 13, 2026
Copy link
Contributor

@thetaPC thetaPC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: angular @ionic/angular package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants