-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
fix(vue): replacing routes now updates location state correctly #24721
Conversation
One thing I am still trying to figure out is if we should be clearing out the tabs history at all when we call When clearing out location history, maybe we could get a list of the cleared routes and remove those same routes from the tabs history? Might be a bit of a performance overhead, but I worry that simply clearing out tabs history will cause unexpected issues down the road. Going to investigate this more prior to merge, but let me know if you have any thoughts. |
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.
This LGTM 👍 Re: clearing out tabs, I'm hesitant to touch more than needed at once with router stuff; LMK if your investigation turns up anything but I'd want a strong repro/use case before forming opinions.
Agreed. I couldn't think of a use case where this is relevant. I am in favor of leaving it alone for now until we get feedback from the community. |
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.
Looks good to me. Agreed the discussion regarding leaving tabs alone for now.
Pull request checklist
Please check if your PR fulfills the following requirements:
npm run build
) was run locally and any changes were pushednpm run lint
) has passed locally and any fixes were made for failuresPull request type
Please check the type of change your PR introduces:
What is the current behavior?
Issue Number: resolves #24432
There are a few related issues:
When the incoming route had
routeAction === 'replace'
Ionic Vue would determine the leaving location by getting the second to last item in location history. This was fine when popping would remove items from location history automatically (I.e. what Ionic React does), but when you supportrouter.go(n)
you cannot do that. As a result, thelocationHistory.previous()
call was not always returning the correct previous route based on where the user was in location history.The
routeInfo.tab === undefined
check was actually a bandaid for an issue I had run into when calling the oldupdateByHistoryPosition
method (See:ionic-framework/packages/vue-router/src/router.ts
Line 294 in a09d7d4
When re-writing history, Ionic Vue never considered the case where you wanted to replace the current state of the route with another route and as a result, the location history was not being updated/wiped appropriately. This worked fine when you navigated backwards and then did a
router.replace
, but if you just did arouter.replace
on its own, location history did not update properly.What is the new behavior?
.previous
method in favor of calling.current
which takes into account your location within history. I also removed theprevious
method in general as it is no longer used in the codebase.routeInfo.tab
bandaid.router.replace
in order to determine if we should wipe the location history.cy.wait
that was not needed. I removed that.Does this introduce a breaking change?
Other information