vuetify: [Bug Report] v-menu: item in activator slot disappears when pushing route
EDIT: repro https://github.com/vuetifyjs/vuetify/issues/10578#issuecomment-612163991
Environment
Vuetify Version: 2.2.12 Vue Version: 2.6.11 Browsers: Chrome 80.0.3987.100 OS: Linux x86_64
Steps to reproduce
- Add a
v-menulike the following:
<v-menu
ref="date-picker"
v-model="showingPicker"
:close-on-content-click="false"
offset-y
max-width="290px"
min-width="290px"
>
<template v-slot:activator="{ on }">
<v-text-field
v-model="dateFormatted"
hint="MM/DD/YYYY format"
persistent-hint
:outlined="true"
append-icon="mdi-calendar"
@blur="updatedInputDate()"
v-on="on"
></v-text-field>
</template>
<v-date-picker v-model="date" no-title @input="selectedCalendarDate()"></v-date-picker>
</v-menu>
- Navigate to another view via:
this.$router.push('/somewhere'). - The
v-text-fieldelement will disappear
Expected Behavior
The v-text-field element should not disappear
Actual Behavior
The v-text-field element will disappear
Other comments
Also, is it possible attach v-on to the @click:append-icon event?
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 11
- Comments: 41 (2 by maintainers)
Commits related to this issue
- feat(VMenu): port to v3 (#14030) fixes #3303 fixes #5310 fixes #9753 fixes #10578 fixes #11818 fixes #12110 — committed to vuetifyjs/vuetify by KaelWD 3 years ago
This problem is related to transitions aplied to routes and the use of v-slot:activador. In my projects I use a app-bar with some buttons with tooltips. Instead of using v-slot:activator, I have used the props activator in tooltips. Example: v-slot:activator
Props activator
This problem can be seen in many others v-slot:activator, including v-menu.
I am having this issue. Whenever route changed, the element in
<template v-slot:activator="{ on }">...</>disappears…The problem is related to the transitions feature on the router in nuxt.
By disabling the transitions feature in
nuxt.config, the problem disappear. So hope this clue will help you find a solution to be able to enable transition on router and fix the problem in vuetify.I had pretty much the same issue, I solved it by adding the
attachprop on myv-menu.Maybe it can also help here 😃
looking for a fix as well without nuxt
I think I found out a situation where it is happening, and how to solve it. At least in my case.
When the structure inside the
<template v-slot:activator="{ on }"> ... </template>changes. The rendering breaks. So if you have av-ifinside that template that switches between different elements, it breaks.Can somebody confirm this?
We actually ended up swapping this component out but I will try to create a vanilla reproduction case this week. That said, I can tell you it is still happening in our code if I add the control back.
I was having similar issues and I decided to actually debug through Vue rendering code to understand what’s going on. It seems like for some reason the
activatorslot ofv-list-groupis treated as a scoped slot and whennormalizeScopedSlots()is invoked, it’s correctly attached to the main $slots property making it available through$slots.activator.But then on subsequent re-renders it skips the
normalizeScopedSlots()algorithm (becauseslots._normalizedis set) and when that happens it no longer attaches the $scopedSlots.activator function to $slots. And thenthis.$slots.activatorbecomes undefined in thev-list-grouprender function.On top of this: I checked Vue docs and Vue suggests always using
this.$scopedSlotsin render functions, even when dealing with the basic kind of slots (source):And if you check the source code of
v-list-groupin this repo, the render function only usesthis.$slots.So what is the solution?
To define the
activatorslot using the old syntax that attaches it to$slotsnot$scopedSlots.So do it like this:
Not like this:
As @eikooc commented I had this issue because the only child of
<template v-slot:activator="{ on }"></template>had av-ifthat was toggling it’s visibility.I solved it by wrapping the “activator button” (
<my-button>in this example) in adivthat is not bound to thev-if:Good for ya. 😃 What about in a Vue stack that doesn’t have Nuxt… like in my examples?
I tried to reproduce it and I found that I am not able to reproduce it only with Vuetify and vue-router. But I was able to reproduce it with nuxt. I dont know why within nuxt the problem is present.
I prepared a simple codesandbox to show this.
https://w63ms.sse.codesandbox.io/
Scenario: By navigation from /about to home page, The dropdown button dissapear until the Home page is rendered completely.
@eikooc this is not look like to be related to structure inside template v-slot
@jacekkarczmarczyk Is it possible to investigate and maybe reopen the issue?