Skip to content

fix(vue): correct route is replaced when using router.replace - #24533

Merged
liamdebeasi merged 1 commit into
mainfrom
FW-345
Jan 10, 2022
Merged

liamdebeasi merged 1 commit into
mainfrom
FW-345

Conversation

@liamdebeasi

Copy link
Copy Markdown
Contributor

Pull request checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)
  • Build (npm run build) was run locally and any changes were pushed
  • Lint (npm run lint) has passed locally and any fixes were made for failures

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Issue Number: resolves #24226

Previously I had thought that issue was related to ion-router-outlet not waiting for the previous transition to finish. This finding was incorrect. The real issue was that the replace logic inside of IonRouter was replacing the wrong route.

Currently, IonRouter gets the last item in the Location History array for the route that should be replaced:

const currentRouteInfo = locationHistory.last();

This line (incorrectly) assumes that the last item in the Location History is the current route. Consider the following example:

History: /page1 --> /page2.

If you do router.go(-1), you will now be on /page1. If you were to then do router.replace('/page3') one would expect Ionic to replace /page1 with /page3. However, since it was grabbing the last item in the Location History, Ionic was replacing /page2 with /page3.

What is the new behavior?

  • Router now gets the current route according to calculated deltas rather than grabbing the last item in the array.

Does this introduce a breaking change?

  • Yes
  • No

Other information

@liamdebeasi
liamdebeasi requested a review from a team January 7, 2022 19:16
@github-actions github-actions Bot added the package: vue @ionic/vue package label Jan 7, 2022

@sean-perkins sean-perkins 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.

Looks good to me 👍

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.

bug: vue, router-outlet not waiting for previous transition to finish

3 participants