Skip to content

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

Merged
ShaneK merged 3 commits into
major-9.0from
FW-6962
May 19, 2026
Merged

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

Conversation

@ShaneK

@ShaneK ShaneK commented May 15, 2026

Copy link
Copy Markdown
Member

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

vercel Bot commented May 15, 2026

Copy link
Copy Markdown

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

@thetaPC thetaPC left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@ShaneK ShaneK merged commit ee190ee into major-9.0 May 19, 2026
138 of 142 checks passed
@ShaneK ShaneK deleted the FW-6962 branch May 19, 2026 13:02
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.

2 participants