Skip to content

fix(vue-router): invoke beforeRouteEnter next() callbacks with component instance#31150

Open
ShaneK wants to merge 3 commits into
major-9.0from
FW-6962
Open

fix(vue-router): invoke beforeRouteEnter next() callbacks with component instance#31150
ShaneK wants to merge 3 commits into
major-9.0from
FW-6962

Conversation

@ShaneK
Copy link
Copy Markdown
Member

@ShaneK ShaneK commented May 15, 2026

Issue number: resolves #25013


What is the current behavior?

A beforeRouteEnter(to, from, next) guard that calls next((vm) => vm.member = 5) never runs the callback. Vue Router's <router-view> invokes whatever ends up in matchedRoute.enterCallbacks[name] from a post-flush watcher once the view's instance is set, but IonRouterOutlet does its own rendering and skips that step. matchedRoute.instances.default gets populated in registerIonPage, so internal guards still fire, but the queued enter callbacks sit there unused

What is the new behavior?

createViewStacks's registerIonPage now reads matchedRoute.enterCallbacks.default, resets it, and runs each callback with the resolved instance. The reset happens before invocation so a callback that triggers a synchronous navigation can push fresh entries onto the next matched record without getting wiped. There's a new Vitest case in routing.spec.ts that navigates into a page whose beforeRouteEnter does next((vm) => { vm.member = 5 }) and asserts both the callback ran with the instance and the mutation reached the DOM

Does this introduce a breaking change?

  • Yes
  • No

Other information

@ShaneK ShaneK requested a review from a team as a code owner May 15, 2026 13:19
@ShaneK ShaneK requested a review from BenOsodrac May 15, 2026 13:19
@vercel
Copy link
Copy Markdown

vercel Bot commented May 15, 2026

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

Project Deployment Actions Updated (UTC)
ionic-framework Ready Ready Preview, Comment May 15, 2026 4:15pm

Request Review

@github-actions github-actions Bot added the package: vue @ionic/vue package label May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: vue @ionic/vue package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant