Repository navigation
Description
Bug Report
Ionic version:
[ ] 4.x
[x] 5.x
Current behavior:
When navigating between pages navigation breaks and page is not becoming visible.
The page we are navigating from is still in DOM as well as the new (even though router-direction is root), and have the same z-index.
We have experienced the issue when navigating with the help of sideMenu, but not sure if its only related to this.
We have also only experienced it while navigating from a dynamic url to a static url.
Link to video showing error occurring:
https://vimeo.com/488869055/6e4ba7b774
We are getting the following error:
Uncaught (in promise) TypeError: Cannot read property 'classList' of undefined
at handlePageTransition (index.js?8a30:930)
it's related to this line of code:
| leavingEl.classList.add('ion-page-hidden'); |
It looks like some sort of reference to the DOM object is lost.
leavingViewItem.ionPageElement seems to be undefined when the error occurrs.
Expected behavior:
Navigation not to break, and the page we are navigating from to be removed from DOM.
Steps to reproduce:
I have created a repo with minimal code to reproduce the error:
https://github.com/torgnywalin/ionic-vue-debug-routing
This repo is based on the starter template sidemenu and are created with this command:
ionic start ionic-vue-debug-routing sidemenu --type vue
All changes i have done is in this commit:
torgnywalin/ionic-vue-debug-routing@8683d13
Click randomly on the links in sidemenu, and go between the "folder" pages, and the test page.
After a while it should break when navigating to the test page. (See video link above)
Related code:
Full code:
https://github.com/torgnywalin/ionic-vue-debug-routing
Navigation in sideMenu:
<ion-menu-toggle auto-hide="false" v-for="(p, i) in appPages" :key="i">
<ion-item @click="selectedIndex = i" router-direction="root" :router-link="p.url" lines="none" detail="false" class="hydrated" :class="{ selected: selectedIndex === i }">
<ion-icon slot="start" :ios="p.iosIcon" :md="p.mdIcon"></ion-icon>
<ion-label>{{ p.title }}</ion-label>
</ion-item>
</ion-menu-toggle>
<ion-menu-toggle auto-hide="false">
<ion-item router-direction="root" :router-link="'/test'" lines="none" detail="false" class="hydrated">
<ion-icon slot="start" name="home"></ion-icon>
<ion-label>Test</ion-label>
</ion-item>
</ion-menu-toggle>Other information:
While troubleshooting i found some other issues that references the same console error:
#22286
#22166
Both are closed.
Ionic info:
Ionic:
Ionic CLI : 6.12.2 (/Users/torgnywalin/.nvm/versions/node/v14.7.0/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/vue 5.5.1
Capacitor:
Capacitor CLI : 2.4.4
@capacitor/core : 2.4.4
Utility:
cordova-res : not installed
native-run : not installed
System:
NodeJS : v14.7.0 (/Users/torgnywalin/.nvm/versions/node/v14.7.0/bin/node)
npm : 6.14.7
OS : macOS Big Sur
Activity
[-]bug: Serious navigation bug (ionic-vue)[/-][+]bug: ionic vue transition gets incorrect view item on dynamic url[/+]liamdebeasi commentedon Dec 9, 2020
Thanks for the issue. Can you try the following dev build and let me know if it resolves the issue?
torgnywalin commentedon Dec 9, 2020
Thanks for the quick response. I've tested and was not able to reproduce within 5-10 minutes of testing.
Before upgrading i was able to reproduce within 10-15 seconds, so seems like it's fixed.
torgnywalin commentedon Dec 10, 2020
@liamdebeasi I'm sorry to inform that we noticed another bug, that I think is related to this one.
When we have navigated through some static and some dynamic urls, going back with IonBackButton is breaking.
I have updated the example repo with code to reproduce:
https://github.com/torgnywalin/ionic-vue-debug-routing
Changes are in this commit:
torgnywalin/ionic-vue-debug-routing@4da643a
To reproduce
All navigation is done with
router.push(url)/home)/folder/start/folder/page1/folder/page2/testIonBackButtonto go back through the stackWhen returning from the dynamic URLs to home, we end up with almost same problem as in original issue.
Both pages are stuck in DOM and have same
z-index.We have only seen it if we go from static URL -> dynamicURL -> dynamicURL -> staticURL.
So a static before and after some dynamic pages.
Video of it happening:
https://vimeo.com/489404765/b21f0b5510
torgnywalin commentedon Dec 10, 2020
I didn't see #22658, they might be related.
liamdebeasi commentedon Dec 10, 2020
Yeah looks like the same issue. I am close to finishing a fix for #22658, so I will post a new dev build here when that is ready.
liamdebeasi commentedon Dec 10, 2020
Can you try the following dev build and let me know if it resolves the issue?
torgnywalin commentedon Dec 10, 2020
Thanks for super quick response.
Did a quick test on example repo and seems to work.
Will try the new packages on more complex project tomorrow and test there as well.
I have a question regarding the vue-router implementation in Ionic:
I have asked on the forum, and understand if you dont have time to answer it, but thought i give it a try
Is there a way to get the animation between pages when navigating between dynamic urls using the same component?
For example:
/home/folder/page1(we get transition)/folder/page2(we dont get transition)/test(we get transition)Is there a way to get transitions on the navigation between page1 and page2?
Or is there a plan to implement this?
I have used Ionic-Angular for a long time, and there i think it was solved with IonicRouteStrategy.
liamdebeasi commentedon Dec 10, 2020
Good question. Ionic Vue (correctly) reuses the view when going from
/folder/page1to/folder/page2, but since the component is already "visible" there is no transition. I think we need to do something similar to what Ionic React does. When transitioning to another version of the same component, Ionic React clones the element temporarily so there is a transition:ionic-framework/packages/react-router/src/ReactRouter/StackManager.tsx
Lines 166 to 175 in 91aaaab
torgnywalin commentedon Dec 10, 2020
Yeah, sound like that could work for Vue as well.
I think with the fixes you have done in the last days, and if/when we get a fix for this as well, that would make for a really good and consistent navigation experience.
We make a lot of apps with menus in tree structure, so we often navigate from
/menu/:idto/menu/:id.So this would make the user experience even better.
torgnywalin commentedon Dec 11, 2020
As expected it worked fine in our larger project as well. Not able to reproduce.
jofleck commentedon Dec 13, 2020
Same problem. With the dev build which was posted by @liamdebeasi the problem is not reproducible for me anymore. Wuhuuu 👍
fix(vue): correctly determine leaving view when transitioning to a ne…
liamdebeasi commentedon Dec 16, 2020
Thanks for the issue. This has been resolved via #22655, and a fix will be available in an upcoming release of Ionic Framework.
ionitron-bot commentedon Jan 15, 2021
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.