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): correct views are now unmounted in tabs #25270

Merged
merged 6 commits into from
May 18, 2022
Merged

fix(vue): correct views are now unmounted in tabs #25270

merged 6 commits into from
May 18, 2022

Conversation

liamdebeasi
Copy link
Contributor

@liamdebeasi liamdebeasi commented May 10, 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?

When using router.go() it is possible for users to navigate back over multiple views:

/page1 --> /page2 --> /page3 --> router.go(-2)

The above example will bring the user back to /page1. Since Ionic renders multiple views in the DOM at the same time, it is important that we unmount any intermediary views. For example, if we did not unmount intermediary views then the view for /page2 would never get unmounted. This can result in a DOM node leak. Similarly, we need to re-mount intermediary views if you then called router.go(2).


For apps that route in a linear manner, this is fine. However, there is a fundamental incompatibility between nested outlets in Ionic (such as tabs) and router.go(). The reason is that router.go() expects routing to be done in a linear manner (such as the example above). Nested outlets such as tabs are fundamentally non-linear. As a result, router.go() typically will not yield the results that developers are expecting.

In the linked issue below, we were trying to anticipate router.go() usage which resulted in the wrong view items being unmounted (essentially we tried to unmount an undefined view item).

Issue URL: resolves #25255

What is the new behavior?

  • Apps that do not use linear routing no longer have intermediary views unmounted/mounted. This means that router.go() will not be compatible with non-linear applications. In fairness, we never actually supported router.go() in non-linear environments. The problem was that when we added router.go() support for linear environments, we never put any limits on when it could be used because we were unaware of the tradeoffs at the time of implementing.
  • I have also added docs that explain how non-linear routing works as well as the tradeoffs (I.e. no router.go support) docs(angular, react, vue): add docs on linear vs non-linear routing ionic-docs#2333

Does this introduce a breaking change?

  • Yes
  • No

Other information

Dev build: 6.1.5-dev.11652207609.1ba60afe

@github-actions github-actions bot added the package: vue @ionic/vue package label May 10, 2022
@liamdebeasi liamdebeasi changed the title fix(vue0 fix(vue): correct views are now unmounted in tabs May 10, 2022
@liamdebeasi liamdebeasi reopened this May 10, 2022
@liamdebeasi liamdebeasi requested review from amandaejohnston, sean-perkins and a team and removed request for a team May 10, 2022 20:09
@liamdebeasi liamdebeasi marked this pull request as ready for review May 10, 2022 20:09
@liamdebeasi liamdebeasi requested a review from a team as a code owner May 10, 2022 20:09
@@ -66,7 +66,8 @@ describe('Tabs', () => {

cy.ionPageVisible('tab1');

cy.ionPageDoesNotExist('tab1childone');
// TODO(FW-1420)
//cy.ionPageDoesNotExist('tab1childone');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is still an issue which is why I am commenting it out. It was previously working by chance and I mistakenly thought it was fixed so I uncommented this line.

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, switching tabs causes wrong view to be unmounted
3 participants