-
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
bug: ionic vue, ionic react incorrect view rendered when using router.go(n) and n < -1 #22563
Comments
Thanks, I can reproduce this. When you do |
Any chance to get a build with this fix and #22540 ? 😛 |
#22540 was already fixed and should be shipping out soon. I've assigned this one to a milestone so you can track our progress on the milestones page: https://github.com/ionic-team/ionic-framework/milestones. The milestone assignment is subject to change, but it should give you a rough idea of how close fixes are to shipping. |
Took a closer look at this. Turns out this is the same issue as #22400 in Ionic React, which makes sense since Ionic Vue and Ionic React share similar routing integration code. The main problem is we do not know how many pages a user has gone back, which makes fixing this tricky. It looks like this is not a problem in Ionic Angular, so I will probably look there for some hints on how to solve this. edit: Removing this from the 5.5.3 milestone as it is unlikely I will be able to solve, test, and merge this by next week. |
I encountered the same problem, which was introduced in ionic/react 5.3.0, it still exists in ionic/react 5.5.2. You may be able to refer to version 5.2.3 to solve the problem. |
Any suggestions for a workaround? The only thing we have found so far is a window.location.reload. Which is far from acceptable for the user experience of the app. |
Is there an update on this issue and/or new milestone planned for the fix? Many thanks, Ronald |
With a deep diving into the source code, I didn't find an easy way to solve this issue :( |
Unfortunately, I don't think the routers give us enough information to solve this bug. The main thing we would need is information on how many pages the user went back (I.e. the |
Also this used to work in the older version of Ionic React mainly by chance as it was pretty aggressive with pruning its internal view stack. This behavior caused some other unintended issues which is why the behavior changed starting in Ionic React 5.3.0. |
This is a game breaker for us (Vue). Another reproduction: https://github.com/mattsteve/ionic-vue-router-go-broken By the way, I can't even chain router.go(-1) in a loop. It still goes back only 1 page. This is probably a similar, but related issue. Router should remember all the commands that were ordered and not ignore them because a transition animation is playing. |
By the way, @modus/ionic-vue doesn't have this bug. Maybe worth studying their code. |
@modus/ionic-vue relies on the |
Well, it was working good for our purposes. Would rather have a small performance hit on low-end devices than have a major bug like this. |
+1 |
Our navigation really breaks for the user, especially on native apps. We are forced to do a history.replace, which gives really unexpected behavior for users when they use the native back button, it brings them back to Home page After doing some stuff on Page 3, there is nothing to do anymore for them on Page2, so we want to send them back to Page 1. If they would press back from there, they would go back to Home (which is expected and logical in our navigational structure) the alternative history.push(Page1) does not work either, pushing back will send them back to Page3. Our main menu (tabs , profile buttons, etc) is in Home, so they feel stuck... this is really a very bad bug in terms of user experience. |
While not perfect you can still workaround it by using a reactive variable to know when to trigger
You can implement what i said with something like this on Page2:
You would need to set |
we are using react, but I guess the same applies there. It is an interesting workaround, thanks! We have created another workaround and override the backbutton on Page 1, it always goes back to Home, so people don't get stuck. This works because of the hierarchy we have in the app, but it does not work for native back. (swipe on iOS). |
@liamdebeasi Can't you use beforeEach in addition to afterEach to examine the change to window.history.length to detect this scenario? |
I'll take a look and see if that is something we can use. Thanks! |
We should be able to use Nothing to announce in terms of ETA right now as I need to do more research on this feature, but when I have something I will be sure to provide a dev build so you can all test it out and provide feedback. |
Hi everyone, Quick update on things: Turns out Vue Router has an undocumented
As this is a development build of Ionic, please do not use this in production. Note on Ionic React: According to remix-run/history#36 (comment) and remix-run/history#334 (comment), it does not seem like React Router exposes a delta value. The |
Routing backwards multiple pages looks to work, though there is some behavior I'm not expecting, if I do this: router.push({ name: 'page1' });
// Wait for router animation...
// User types in some inputs...
router.push({ name: 'page2' });
// Wait for router animation...
router.go(-2);
// Wait for router animation...
router.push({ name: 'page1' });
// The text that user typed in page1 is still there, so the page wasn't destroyed It seems page1 is kept in memory and was never unmounted & remounted. I expect every There's also another problem; I'm trying to figure out which command triggers it. |
Yeah, I don't know, Edit: Ok, it's not that Edit: My issue seems to be that my page with Specifically adding an |
Thanks for testing! Here is a new dev build which should fix the mount issue in #22563 (comment):
I will investigate the replace behavior in #22563 (comment) this week. |
Looks good |
Regarding the I can reproduce the issue in #22563 (comment) on Ionic Vue 5.6.13, so it does not seem to be related to the dev build. I will keep this issue open for a few more days to give others more time to test. If all goes well, we should be able to get this into an upcoming release of v5. |
Yeah, that's what I said initially. I was just saying it used to work without it, I suppose it automatically added the ".ion-page" class to the |
I have not changed anything regarding tabs. I need to clean up the code for this patch, so I will keep my eye out for anything that may have caused that behavior change. |
Thanks for the issue. This has been resolved via #23773, and a fix will be available in an upcoming release of Ionic Framework. I have created #23775 which is a continuation of this issue for Ionic React developers. This thread is pretty Vue-specific, so I felt it would be useful to give React its own thread in case there are any differences in implementation. |
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. |
Bug Report
Ionic version:
[ ] 4.x
[x] 5.x
Current behavior:
Trying to go back 2 or more routes.
Expected behavior:
App navigates back X amount of routes as long as there's that many in the history stack
Steps to reproduce:
Related code:
https://github.com/NunoSav/ionic-vue3-router-go-back
Other information:
I also made a vue3+router sample that mirrors the one above but without Ionic in it to see if the issue was with vue-router itself, it wasn't. You can check it here https://github.com/NunoSav/vue3-router-go-back
Ionic info:
The text was updated successfully, but these errors were encountered: