Skip to content

fix(angular): ignore swipe back with popped stack - #31712

Open
officialasishkumar wants to merge 1 commit into
ionic-team:mainfrom
officialasishkumar:fix/angular-swipe-back-popped-stack
Open

officialasishkumar wants to merge 1 commit into
ionic-team:mainfrom
officialasishkumar:fix/angular-swipe-back-popped-stack

Conversation

@officialasishkumar

Copy link
Copy Markdown

Issue number: resolves #31291


What is the current behavior?

The swipe back gesture on ion-router-outlet checks canGoBack when the pointer goes down, but only calls startBackTransition once the pointer passes the gesture threshold. If a navigation finishes in between (for example navCtrl.back(), a guard redirect or replaceUrl), only one view is left in the stack and startBackTransition throws:

TypeError: Cannot read properties of undefined (reading 'animationBuilder')

The throw also leaves the outlet's gesture marked as in progress, so swipe back stops working until the outlet is recreated.

What is the new behavior?

  • startBackTransition does nothing when there is no view to go back to, the same as when canStart returns false.
  • ion-router-outlet already handles a gesture that started no transition, so the gesture ends cleanly and later swipes work.
  • Added an e2e test that holds the pointer down, pops the stack with history.back(), and then moves the pointer past the threshold. It also checks that a later swipe still goes back.

Does this introduce a breaking change?

  • Yes
  • No

Other information

I ran this on the ng22 test app in Chromium. Without the fix, the new test fails with the TypeError from the issue. With the fix, it passes, along with swipe-animated-disabled, swipe-gesture-disabled, tab-lifecycle and lazy/routing.

Return early from startBackTransition when there is no view to go back
to. The swipe gesture checks canGoBack when the pointer goes down, but
only starts the transition once the pointer passes the gesture
threshold. A navigation finishing in between left a single view in the
stack, so reading animationBuilder from the missing entering view threw
a TypeError. The throw also left the outlet's gesture marked as in
progress, which disabled swipe back until the outlet was recreated.

closes ionic-team#31291
@vercel

vercel Bot commented Nov 7, 2026

Copy link
Copy Markdown

@officialasishkumar is attempting to deploy a commit to the Ionic Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the package: angular @ionic/angular package label Nov 7, 2026

This branch has not been deployed

No deployments
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.

bug: angular swipe-back gesture crashes in StackController.startBackTransition when the stack is popped before the gesture is captured

1 participant