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

bug: Vue: ion-router-outlet not passing Route Props #22472

Closed
CoinBR opened this issue Nov 10, 2020 · 14 comments · Fixed by #22476
Closed

bug: Vue: ion-router-outlet not passing Route Props #22472

CoinBR opened this issue Nov 10, 2020 · 14 comments · Fixed by #22476
Labels
package: vue @ionic/vue package type: bug a confirmed bug report
Milestone

Comments

@CoinBR
Copy link

CoinBR commented Nov 10, 2020

Bug Report

Ionic version:
[x] 5.x (Vue)

Current behavior:
When I setup Vue routes with props, the ion-router-outlet they not get passed to the Vue Component.

Expected behavior:
The Router props should be passed through ion-router-outlet to the Vue Component.

Steps to reproduce:

  1. Create a route with props, example:
    { path: '/auth/login', component: () => import ('../views/LoginRegister.vue'), props: { action: 'Sign In' }, },

  2. use <ion-router-outlet>

  3. Try to access the route props in the component:
    setup(props){ console.log(props.action)

Other information:
I switched it to <vue-router>, and the props got passed.

Another user pointed that <ion-router-outlet> is not actually wrapping <vue-router>. It is actually a custom ionic implementation.
Still, it is important that it can forward props, and any other information that is in the <vue-router> api.

@ionitron-bot ionitron-bot bot added the triage label Nov 10, 2020
@liamdebeasi liamdebeasi added package: vue @ionic/vue package type: bug a confirmed bug report labels Nov 10, 2020
@liamdebeasi liamdebeasi added this to the 5.5.0 milestone Nov 10, 2020
@ionitron-bot ionitron-bot bot removed the triage label Nov 10, 2020
@liamdebeasi
Copy link
Contributor

Thanks, I can reproduce the issue. I will work on a fix.

@liamdebeasi
Copy link
Contributor

liamdebeasi commented Nov 11, 2020

Thanks for the issue. Can you try the following dev build and let me know if it resolves the issue?

npm install @ionic/vue@5.5.0-dev.202011111507.99fd583 @ionic/vue-router@5.5.0-dev.202011111507.99fd583

@CoinBR
Copy link
Author

CoinBR commented Nov 11, 2020

Thank you Liam!
I tested, and it is working: I'm getting the props now.

I still have another problem with , but I'll double check it first before opening a new issue:

Uncaught (in promise) TypeError: Cannot read property 'classList' of undefined
    at handlePageTransition (index.js?8a30:920)

Anyway, the props problem is fixed =) Thanks!

@CoinBR CoinBR closed this as completed Nov 11, 2020
@CoinBR CoinBR reopened this Nov 11, 2020
@CoinBR
Copy link
Author

CoinBR commented Nov 11, 2020

Not sure if I'm supposed to close the issue, Sorry =(

@liamdebeasi
Copy link
Contributor

Glad it works! I will keep this issue open until the PR gets merged in.

@liamdebeasi
Copy link
Contributor

Thanks for the issue. This has been resolved via #22476, and a fix will be available in an upcoming release of Ionic Framework.

TakumaKira pushed a commit to TakumaKira/ionic-framework that referenced this issue Nov 13, 2020
@uriannrima
Copy link

uriannrima commented Nov 19, 2020

Thank you Liam!
I tested, and it is working: I'm getting the props now.

I still have another problem with , but I'll double check it first before opening a new issue:

Uncaught (in promise) TypeError: Cannot read property 'classList' of undefined
    at handlePageTransition (index.js?8a30:920)

Anyway, the props problem is fixed =) Thanks!

It seems to happen when the "root" element rendered by the route isn't a IonPage. It happens with me when I try to use Vue Fragment as root node with an Ion page and Ion menu.

Edited: Jô is my wife nickname, lol.

@uriannrima
Copy link

I'm also sad to learn (from the IonRouterOutlet code comment) that named views are not supported.

@liamdebeasi
Copy link
Contributor

It seems to happen when the "root" element rendered by the route isn't a Jô page. It happens with me when I try to use Vue Fragment as root node with an Ion page and Ion menu.

Thanks! I can keep an eye out for this.

I'm also sad to learn (from the IonRouterOutlet code comment) that named views are not supported.

We don't have named views in IonRouterOutlet at the moment, but if you have a use case for it please feel free to open a feature request.

@uriannrima
Copy link

@liamdebeasi I'm trying to make a side menu that could change per route, but it wouldn't be hard to find a workaround it, but I really would like to make a question about the allowed properties on some ion components while using JSX with Typescript: For some reason I'm allowed to add "slot" property to IonButton for example, but I can't in some elements like IonIcon ( while trying to put it at start of IonItem), is it something wrong with my setup or a general problem? Thanks. I would gladly open a bug if it is so. (For someone in need, you may workaround it by adding // @ts-ignore right before the slot property)

@liamdebeasi
Copy link
Contributor

I'm trying to make a side menu that could change per route, but it wouldn't be hard to find a workaround it,

Ok that makes sense. I recommend creating a feature request for this as it will help other developers indicate that they would like this feature.

For some reason I'm allowed to add "slot" property to IonButton for example, but I can't in some elements like IonIcon ( while trying to put it at start of IonItem)

It's hard to say without seeing your code, but you should be able to provide a slot to ion-icon. I recommend posting on our forums first (http://forum.ionicframework.com/) to see if someone can spot what is going wrong. If after that you think this is a bug, feel free to open a bug report here on GitHub.

@CoinBR
Copy link
Author

CoinBR commented Nov 20, 2020

Thank you @uriannrima !

Your solution did work for me. When I place a <ion-page> as the root element of a <ion-router-outlet>, It stop duplicating my views, and stop giving me that error.

It still gives me some warnings about unregistered components, but I think is related to something else that is wrong in my code.

off-topic: is it ok to put an <ion-page> nested inside another <ion-page> ?

@asarach
Copy link

asarach commented Nov 20, 2020

Hi ;
I think I have a related problem;
I am using ionic with vue3 and my routes are like this:
{ path: '/cat/:catId', component: CategoryPage }, { path: '/book/:bookId', component: BookPage }

in both Book an Category i watch for bookId and catId change ;
but the function inside watch is fired many times.

It seems that it watches BookId and CatId ever time I open the page,

I hope its clear i can open an issue and give a more details if not :)
thanks

@ionitron-bot
Copy link

ionitron-bot bot commented Dec 20, 2020

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 ionitron-bot bot locked and limited conversation to collaborators Dec 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: vue @ionic/vue package type: bug a confirmed bug report
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants