Skip to content
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 across nested outlets preserves previous route info #25171

Merged
merged 6 commits into from
Apr 25, 2022

Conversation

liamdebeasi
Copy link
Contributor

@liamdebeasi liamdebeasi commented Apr 21, 2022

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 URL: resolves #25017

When going across nested outlets, we were accidentally wiping the previous route. Given the following scenario:

/top-level-outlet --> /nested-outlet/1 --> (replace) /nested-outlet/2.

When replacing to /nested-outlet/2 we first removed location history starting with /nested-outlet/1 (because it is getting replaced): https://github.com/ionic-team/ionic-framework/blob/main/packages/vue-router/src/router.ts#L374
This is the correct behavior.

However, the routerAction is replace here which means that locationHistory.add also performed another replace operation: https://github.com/ionic-team/ionic-framework/blob/main/packages/vue-router/src/locationHistory.ts#L9-L11

This means that the /top-level-outlet info was wiped before /nested-outlet/2 was added. Since /top-level-outlet was wiped, pressing the ion-back-button in the nested outlet component would not go back to /top-level-outlet.

What is the new behavior?

  • When replacing we ensure that the replace operation only happens once.
  • When adding a test I noticed that the should show first page test is made redundant by the beforeEach hook in nested.js, so I removed it.
  • I also removed a redundant ionPageVisible('nestedchild') call in should go navigate across nested outlet contexts. This check is already done in the beforeEach hook.

Does this introduce a breaking change?

  • Yes
  • No

Other information

We can likely clean up this behavior even further. The logic I removed dates back pretty far in Ionic React: #21693 I'm not really sure it's even needed anymore.

Dev build: 6.1.3-dev.11650490791.156717e3

@liamdebeasi liamdebeasi requested a review from a team as a code owner April 21, 2022 17:02
@github-actions github-actions bot added the package: vue @ionic/vue package label Apr 21, 2022
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, replacing routes can cause replacement to happen 2x
3 participants