ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

bug: vue3.4 the same component with reference route can not jump the problem

Open lvzhenbo opened this issue 1 year ago • 8 comments
trafficstars

Prerequisites

Ionic Framework Version

v7.x

Current Behavior

The inability to jump is simply the original behavior of the vue-router

Expected Behavior

Should have jumped.

Steps to Reproduce

Update vue to 3.4, update @vitejs/plugin-vue to 5.0

Code Reproduction URL

https://github.com/lvzhenbo/tsdm-app/tree/652cd1de3281772d6bdd2642d37b73567918efbc

Ionic Info

[WARN] Error loading @capacitor/ios package.json: Error: Cannot find module '@capacitor/ios/package.json'

   Require stack:
   -
   C:\Users\29422\Desktop\tsdm-app\node_modules\.pnpm\@[email protected]\node_modules\@ionic\cli\lib\project\index.js
   - C:\Users\29422\Desktop\tsdm-app\node_modules\.pnpm\@[email protected]\node_modules\@ionic\cli\lib\index.js
   - C:\Users\29422\Desktop\tsdm-app\node_modules\.pnpm\@[email protected]\node_modules\@ionic\cli\index.js
   - C:\Users\29422\Desktop\tsdm-app\node_modules\.pnpm\@[email protected]\node_modules\@ionic\cli\bin\ionic

Ionic:

Ionic CLI : 7.2.0 Ionic Framework : @ionic/vue 7.6.2

Capacitor:

Capacitor CLI : 5.6.0 @capacitor/android : 5.6.0 @capacitor/core : 5.6.0 @capacitor/ios : not installed

Utility:

cordova-res : not installed globally native-run : not installed globally

System:

NodeJS : v20.9.0 (C:\Program Files\nodejs\node.exe) npm : 10.1.0 OS : Windows 10

Additional Information

No response

lvzhenbo avatar Jan 03 '24 13:01 lvzhenbo

Thanks for the issue! This issue has been labeled as holiday triage. With the winter holidays quickly approaching, much of the Ionic Team will soon be taking time off. During this time, issue triaging and PR review will be delayed until the team begins to return. After this period, we will work to ensure that all new issues are properly triaged and that new PRs are reviewed. In the meantime, please read our Winter Holiday Triage Guide for information on how to ensure that your issue is triaged correctly. Thank you!

ionitron-bot[bot] avatar Jan 03 '24 13:01 ionitron-bot[bot]

Hi there,

Can you please create a reproduction of the issue that includes only the code required to reproduce the problem?

liamdebeasi avatar Jan 03 '24 14:01 liamdebeasi

Thanks for the issue! This issue has been labeled as needs reproduction. This label is added to issues that need a code reproduction.

Please reproduce this issue in an Ionic starter application and provide a way for us to access it (GitHub repo, StackBlitz, etc). Without a reliable code reproduction, it is unlikely we will be able to resolve the issue, leading to it being closed.

If you have already provided a code snippet and are seeing this message, it is likely that the code snippet was not enough for our team to reproduce the issue.

For a guide on how to create a good reproduction, see our Contributing Guide.

ionitron-bot[bot] avatar Jan 03 '24 14:01 ionitron-bot[bot]

Hi there,

Can you please create a reproduction of the issue that includes only the code required to reproduce the problem?

https://github.com/lvzhenbo/ionic-vue3.4

There are two commits here, the latest commit is the incorrect case and the penultimate commit is the correct case. Then it's a matter of clicking on the selection bar to switch routes, and you'll see some one page will refresh and the other won't

lvzhenbo avatar Jan 03 '24 17:01 lvzhenbo

I was creating the demo and realized that it may have nothing to do with the vue version update and everything to do with the @vitejs/plugin-vue version update

Hi there, Can you please create a reproduction of the issue that includes only the code required to reproduce the problem?

lvzhenbo/ionic-vue3.4

There are two commits here, the latest commit is the incorrect case and the penultimate commit is the correct case. Then it's a matter of clicking on the selection bar to switch routes, and you'll see some one page will refresh and the other won't

lvzhenbo avatar Jan 03 '24 17:01 lvzhenbo

Updating from Vue 3.3.13 to Vue 3.4.4 causes the issue to appear. However, I'm still able to reproduce the issue if I remove Ionic Framework from the application. Have you tried reporting this to the Vue team?

liamdebeasi avatar Jan 03 '24 18:01 liamdebeasi

Updating from Vue 3.3.13 to Vue 3.4.4 causes the issue to appear. However, I'm still able to reproduce the issue if I remove Ionic Framework from the application. Have you tried reporting this to the Vue team?

For vue-router this anomaly is instead normal. Related documentation: https://router.vuejs.org/guide/essentials/dynamic-matching.html#Reacting-to-Params-Changes

So I'm guessing that ionic has a workaround for this situation, which is now broken due to a vue version upgrade

lvzhenbo avatar Jan 03 '24 19:01 lvzhenbo

Updating from Vue 3.3.13 to Vue 3.4.4 causes the issue to appear. However, I'm still able to reproduce the issue if I remove Ionic Framework from the application. Have you tried reporting this to the Vue team?

Confirmed that downgrading my project from vue 3.4 to 3.3 resolved this issue. I was not able to find a workaround so that I could stay on 3.4.

It seems vue-router's onBeforeRouteUpdate() is firing and the to route has the correct params... but the props are not being updated with the new parameters. I'm not sure how to coerce the props into seeing the new parameters. Seems like there should be a way...

ih84ds avatar Jan 07 '24 21:01 ih84ds

We had a similar experience. When upgrading to vue 3.4.5 it started to reuse components when routing between two paths using same route with different params (user/1, user/2). Downgrading to 3.3.8 (the version we had before upgrade) solved the issue.

To me it seems like vue is following the vue-router documentation:

  • routes will reuse components when route changes
  • using watcher or onBeforeRouteUpdate to update the component is working.
  • Since component is reused we dont get ionic animations on navigation.

torgnywalin avatar Jan 16 '24 15:01 torgnywalin

Interested in knowing when this will be solved. Is this a vue issue, or is this that the ionic-vue-router should be updated to conform to the new vue-router ?

maelp avatar Jan 17 '24 17:01 maelp

Is this a vue issue, or is this that the ionic-vue-router should be updated to conform to the new vue-router ?

I'm looking into this, but I don't have a good answer at the moment other than that the expected behavior should work. My initial investigation revealed that this watch callback is not firing anymore on route changes: https://github.com/ionic-team/ionic-framework/blob/ad65824722da0eed90ef9e595b743754bfd360b8/packages/vue/src/components/IonRouterOutlet.ts#L69-L70

Doing watch(() => [route]... does not work, but watch(route... does. I need to dig a bit more into why this is the case.


If you need a resolution sooner then I recommend downgrading to Vue 3.3.x for now.

liamdebeasi avatar Jan 17 '24 17:01 liamdebeasi

It appears this new behavior is due to a breaking change in Vue: https://github.com/vuejs/core/issues/9916#issuecomment-1872602294

The commit for this has been reverted because it was a bigger breaking change than the team expected: https://github.com/vuejs/core/issues/9965#issuecomment-1875067499

It sounds like this was already released, so maybe there's something else causing an issue too.

liamdebeasi avatar Jan 17 '24 17:01 liamdebeasi

It appears this new behavior is due to a breaking change in Vue: vuejs/core#9916 (comment)

The commit for this has been reverted because it was a bigger breaking change than the team expected: vuejs/core#9965 (comment)

It sounds like this was already released, so maybe there's something else causing an issue too.

From the changelog, is it related to this pr (https://github.com/vuejs/core/pull/5912) ?

lvzhenbo avatar Jan 17 '24 17:01 lvzhenbo

Yeah that looks like it is related too. I'll start looking into how we can mitigate this inside of Ionic.

liamdebeasi avatar Jan 17 '24 18:01 liamdebeasi

Can everyone try the following dev build and let me know if the issue is resolved in their apps with Vue 3.4+?

npm install @ionic/[email protected] @ionic/[email protected]

If you're using Vite you might need to remove node_modules/.vite before testing (this is a cache and will be re-created when you serve the app again).

liamdebeasi avatar Jan 17 '24 21:01 liamdebeasi

https://github.com/lvzhenbo/ionic-vue3.4 Validated, jumps fine, should be solved

lvzhenbo avatar Jan 17 '24 21:01 lvzhenbo

Can everyone try the following dev build and let me know if the issue is resolved in their apps with Vue 3.4+?

Confirmed. That dev build works with [email protected] for the routes I was experiencing the issue on.

ih84ds avatar Jan 17 '24 22:01 ih84ds

Nice! Will this be released in the next ionic update?

maelp avatar Jan 17 '24 22:01 maelp

Can everyone try the following dev build and let me know if the issue is resolved in their apps with Vue 3.4+?

I can confirm as well, fixed the issue for me.

mneciunas avatar Jan 18 '24 14:01 mneciunas

Thanks for the issue. This has been resolved via https://github.com/ionic-team/ionic-framework/pull/28846, and a fix will be available in an upcoming release of Ionic Framework.

liamdebeasi avatar Jan 19 '24 21:01 liamdebeasi

Thanks! Do you know when the release will be shipped?

maelp avatar Jan 23 '24 09:01 maelp

The bug fix will follow our patch release schedule: https://ionicframework.com/docs/reference/versioning#release-schedule

liamdebeasi avatar Jan 23 '24 14:01 liamdebeasi

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

ionitron-bot[bot] avatar Feb 22 '24 15:02 ionitron-bot[bot]