-
Notifications
You must be signed in to change notification settings - Fork 13.3k
fix(vue-router): clear navigation info when a guard aborts navigation #31364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
thetaPC
wants to merge
19
commits into
main
Choose a base branch
from
FW-6706
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+710
−7
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
e023609
fix(vue-router): clear navigation info when a guard aborts navigation
thetaPC 6d5c199
fix(vue-router): clear staged route params when a guard aborts naviga…
thetaPC 7ae3b16
docs(vue-router): clarify which navigation failures clear staged state
thetaPC b6c6e73
fix(vue-router): clear staged state when a navigation is cancelled
thetaPC d4b89b7
test(vue-router): use data-pageid in routing specs
thetaPC 4bbcc7a
test(vue-router): align routing spec setup with the rest of the file
thetaPC 2dc6efd
test(vue-router): tidy the navigation guard specs
thetaPC 7ff2c5e
fix(vue-router): only clear staged state from the failed navigation
thetaPC b1b2aca
Merge branch 'main' of github.com:ionic-team/ionic-framework into FW-…
thetaPC 1b50d95
docs(vue-router): correct what stages route params and when entries r…
thetaPC 101143e
test(vue-router): cover the back button path and fix a misleading spe…
thetaPC 64a77a6
test(vue-router): read the router through inject instead of the Vue i…
thetaPC 398cb36
test(vue-router): add exclamation
thetaPC 06e0174
test(vue-router): hoist the shared page factory to module scope
thetaPC 67125fe
fix(vue-router): record the target of staged route params
thetaPC 6856c6f
test(vue-router): add definite assignment assertions to the racing specs
thetaPC 6a6032f
docs(vue-router): use a doc block for the staged state comment
thetaPC f40d2d1
test(vue-router): link only the specs that reproduce the issue
thetaPC f469679
test(vue-router): assert the view stack and share the spec helpers
thetaPC File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The gate here was my suggestion, and I missed something when I proposed it. Saving the target path works for the delta, but this line clears
incomingRouteParamstoo, and nothing ever stamps a path onto that. Onlyhistory.listenwritescurrentNavigationInfo.to, and neithersetIncomingRouteParamsnorchangeTabrecords one, so whenever neither navigation is a history traversal the first disjunct is true and the clear runs unconditionally.That regresses against main. With a push in flight on a lazy route, a logout
ionRouter.replace('/login')cancels it, and the cancelled push wipes the replace's staged params before it gets to use them. The route comes outrouterDirection: 'none'withcanGoBack()true, where main gives'root'and false. Without'root'there's noclearHistory(), so the back button on the login page still walks into the authenticated pages after logout. The tab path losestabandrouterAnimationthe same way.I think stamping the resolved path onto
incomingRouteParams, the wayhistory.listenalready stampscurrentNavigationInfo.to, is the fix that keeps the gate honest for both slots. I haven't tried that one. What I did try is skipping just the params clear oncancelledfailures, which gets main's result back with all 20 tests still passing, since 29721's own repro aborts rather than cancels. That leaves anionRouter.back()cancelled by a push still uncleared though, which is why I'd lean toward the stamp.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Went with the stamp.
setIncomingRouteParamsnow takes an optional target and resolves it, and the gate is two independent checks instead of one answer for both slots.goBackandgoForwardleave it unset and fall back to the delta's target, which is fine because those are the ones that hand off to history.One thing I'd like your read on. I kept the target in a separate
incomingRouteParamsTorather than adding atofield toincomingRouteParams. The reason is that the params get spread wholesale onto a RouteInfo at theincomingRouteParams?.idbranch, so a field on them would land there too and reach anything reading route info. The cost is two variables to keep in sync, and I had to clear the stamp in all three places the params are cleared. Happy to move it onto the params if you'd rather have one object, since the leak is cosmetic rather than harmful.67125fe