Skip to content

bug(vue-router): back button blocked by a guard makes the next navigation show the wrong page #31716

Closed

Description

@ImadYamane

Hi Ionic team 👋

Thanks for all your work on Ionic, we really enjoy building with it!

We ran into a small but tricky routing issue in @ionic/vue-router and wanted to share what we found.

What happens

If a user taps IonBackButton and a route guard stops that navigation (for example an "unsaved changes, stay on this page?" check), the next navigation goes a bit wrong: the URL updates correctly, but the outlet still shows the page the blocked back navigation wanted to go to.

How to reproduce

  1. Go from /home to /form.
  2. On /form, tap the back button. A guard (onBeforeRouteLeave(() => false)) keeps you on the page.
  3. Now navigate forward with router.replace('/done').
  4. The URL says /done, but you see the Home page.

Minimal repro (Vite + Vue 3, pnpm install && pnpm test): https://github.com/ImadYamane/ionic-vue-router-aborted-back-repro

Versions

@ionic/vue 8.8.19, @ionic/vue-router 8.8.19, vue 3.5, vue-router 4.5

What we think is going on

In createIonRouter, handleNavigateBack stores incomingRouteParams for the previous page and then calls router.back(). When a guard aborts that navigation, afterEach returns early and those params stay around. The next successful navigation picks them up and renders the old page.

A possible fix

Clearing the pending params when a navigation fails as aborted or duplicated fixed it for us (the patch is in the repro under patches/). We left cancelled navigations alone, since the navigation that replaced them may already have set its own params. It's about 15 lines, and we're happy to open a PR if that helps.

Thanks a lot for taking a look!

Activity

  1. ShaneK commented on Nov 9, 2026

    @ShaneK
    Member

    Thanks for the detailed writeup and the patch! This is the same bug as the guard issue in #29721, which we fixed in #31364 and shipped in 9.0.3. v8 is in maintenance mode now, so it only gets security fixes and we won't be backporting this one. The dates are in our support policy.

    Upgrading @ionic/vue and @ionic/vue-router to 9.0.3 or later should fix it for you. Heads up that v9 needs vue-router 5, so you'll have to bump that too. We have a migration tool that may help you with your move, too! I'm going to close this, but if you still see it on v9 let us know and we'll reopen.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions