Vuetify 3 : v-menu location property not working - vue.js

i have a v-menu on toolbars right corner. The menu displays as bottom right (end) so half the card is outside the view. I want to change to bottom left (start) however i can't seem to make it work.
<v-menu
location="start"
rounded
>
<template v-slot:activator="{ props }">
<v-btn
icon
v-bind="props"
>
<v-avatar
color="brown"
size="large"
>
<span class="white--text text-h5">{{ user.initials }}</span>
</v-avatar>
</v-btn>
</template>
<v-card>
<v-card-text>
<div class="mx-auto text-center">
<v-avatar
color="brown"
>
<span class="white--text text-h5">{{ user.initials }}</span>
</v-avatar>
<h3>{{ user.fullName }}</h3>
<p class="text-caption mt-1">
{{ user.email }}
</p>
<v-divider class="my-3"></v-divider>
<v-btn
rounded
variant="text"
#click="() => goSettings() "
>
Settings
</v-btn>
<v-divider class="my-3"></v-divider>
<v-btn
#click="() => logOut()"
>
Disconnect
</v-btn>
</div>
</v-card-text>
</v-card>
</v-menu>
I'm missing somethings? im checking the example in the docs https://next.vuetifyjs.com/en/components/menus/
thanks
edit: added screenshots of current behaviour vs expected
Edit 2: I tried the v-menu on a codepen and works as intended, however for some reason, it does not work inside a v-app-bar

Try using prop "anchor" instead of "location".
<v-menu
anchor="bottom end"
rounded
>
<template v-slot:activator="{ props }">
<v-btn
icon
v-bind="props"
>
<v-avatar
color="brown"
size="large"
>
<span class="white--text text-h5">{{ user.initials }}</span>
</v-avatar>
</v-btn>
</template>
<v-card>
<v-card-text>
<div class="mx-auto text-center">
<v-avatar
color="brown"
>
<span class="white--text text-h5">{{ user.initials }}</span>
</v-avatar>
<h3>{{ user.fullName }}</h3>
<p class="text-caption mt-1">
{{ user.email }}
</p>
<v-divider class="my-3"></v-divider>
<v-btn
rounded
variant="text"
#click="() => goSettings() "
>
Settings
</v-btn>
<v-divider class="my-3"></v-divider>
<v-btn
#click="() => logOut()"
>
Disconnect
</v-btn>
</div>
</v-card-text>
</v-card>
</v-menu>
I can't even tell you why this could work, because I wasn't able to find it in the Docs or Files, but it is used like that in one of the templates I'm using.
However, this only works for large screens, on mobile the card will be outside the view again.

I had the same problem, the solution is using the activator prop or perhaps, in your case you sould use the internal-activator prop.
<v-menu
location="start"
rounded
internal-activator
>
<template v-slot:activator="{ props }">
<v-btn
icon
v-bind="props"
>
<v-avatar
color="brown"
size="large"
>
<span class="white--text text-h5">{{ user.initials }}</span>
</v-avatar>
</v-btn>
</template>
<v-card>
<v-card-text>
<div class="mx-auto text-center">
<v-avatar
color="brown"
>
<span class="white--text text-h5">{{ user.initials }}</span>
</v-avatar>
<h3>{{ user.fullName }}</h3>
<p class="text-caption mt-1">
{{ user.email }}
</p>
<v-divider class="my-3"></v-divider>
<v-btn
rounded
variant="text"
#click="() => goSettings() "
>
Settings
</v-btn>
<v-divider class="my-3"></v-divider>
<v-btn
#click="() => logOut()"
>
Disconnect
</v-btn>
</div>
</v-card-text>
</v-card>
</v-menu>

Related

Move button closer to the expand button

In Vuetify, if I want to move my delete button closer to the expand button.
How do I do that ?
<v-expansion-panel-header>
{{ vehicle.VIN }}
<v-icon v-if="type == 'saved'" color="teal"> mdi-check </v-icon>
<v-btn
text
v-if="type == 'saved'"
color="red"
#click="remove(index, type)"
>
DELETE
</v-btn>
</v-expansion-panel-header>
You can reset the flex-grow property on the delete button using a Vuetify helper class.
class="flex-grow-0"
Snippet:
<div id="app">
<v-app>
<v-expansion-panel-header>
{{ vehicle.VIN }}
<v-icon v-if="type == 'saved'" color="teal"> mdi-check </v-icon>
<v-btn
class="flex-grow-0"
text
v-if="type == 'saved'"
color="red"
#click="remove(index, type)"
>
DELETE
</v-btn>
</v-expansion-panel-header>
</v-app>
</div>
Vuetify Docs: https://vuetifyjs.com/en/styles/flex/#flex-grow-and-shrink
It can also be achieved using row and column-
<v-expansion-panel-header>
<v-row no-gutters>
<v-col>
hello
</v-col>
<v-col>
<v-icon color="teal"> mdi-check </v-icon>
</v-col>
<v-col align="right">
<v-btn text color="red">
DELETE
</v-btn>
</v-col>
</v-row>
</v-expansion-panel-header>

User both "to" prop in a v-card and some buttons inside the "actions" section in Vuetify

I have a card like this:
<v-card :to="groupRoute" class="group-card mx-auto" color="#26c6da" dark max-width="400">
<v-card-title>
<span class="text-h6 font-weight-light d-flex" style="width: 100%">
<span class="name">{{ group.name }}</span>
<span class="flex-grow-1" />
<span class="creation">{{ creation }}</span>
</span>
</v-card-title>
<v-card-text class="text-h6 font-weight-bold">"{{ group.description }}"</v-card-text>
<v-card-actions>
<v-icon class="mr-1">mdi-account</v-icon>
<span class="partecipants subheading mr-2">
<span class="partecipants">{{ group.partecipants.length }}</span>
<span class="mx-1">/</span>
<span class="maxPartecipants">{{ group.maxPartecipants }}</span>
</span>
<v-row align="center" justify="end">
<v-btn class="blue--text text--darken-3" text icon #click="edit">
<v-icon>mdi-pencil</v-icon>
</v-btn>
<v-btn color="red" class="mr-2" icon #click="delete">
<v-icon>mdi-delete</v-icon>
</v-btn>
</v-row>
</v-card-actions>
</v-card>
Note that the only important parts are: :to="groupRoute" and the <v-card-actions> with the two buttons.
The problem here is that the fact that the card has to, overwrites the click methods on the buttons, so even if I click the button and not the whole card, I am redirected to the groupRoute.
Change #click to #click.prevent to trigger preventDefault of the event

v-date-picker customize it and have today, last 7 days beside it

Hi just got a question if this kind of thing is possible?
enter image description here
this is so far I have done.
<template>
<v-row align="center">
<v-checkbox
v-model="landscape"
label="Landscape"
></v-checkbox>
<v-date-picker
v-model="picker"
landscape
></v-date-picker>
</v-row>
</template>
I solved it using v-card. It was challenging one and been looking for the answer all over, I was like crashing my head on it. The output would be like this:
enter image description here
The complete code:
<template v-if="filters">
<div class="d-flex justify-lg-space-between filter__activities">
<v-text-field
v-model="searchInText"
outlined
dense
append-icon="fas fa-search"
placeholder="Search"
/>
<div class="px-2" />
<v-select
v-model="searchInSelect"
append-icon="fas fa-chevron-down"
item-color="lucky-point"
placeholder="Category"
outlined
dense
:items="types"
:menu-props="{ bottom: true, offsetY: true }"
class="lucky-point--text"
/>
</div>
<div class="filter__activities">
<v-menu
ref="menu1"
v-model="menu1"
:close-on-content-click="false"
transition="scale-transition"
offset-y
bottom
min-width="auto"
>
<template v-slot:activator="{ on }">
<v-text-field
:value="computedDateFormatted"
outlined
dense
placeholder="Select Date"
append-icon="mdi-calendar"
v-on="on"
/>
</template>
<v-card>
<div class="d-flex">
<div class="pa-2 py-16">
<div class="py-1">
<v-btn
plain
class="text-capitalize text-subtitle-1 mine-shaft--text filter__activities-active-btn"
>
Today
</v-btn>
</div>
<div class="py-1">
<v-btn
plain
class="text-capitalize text-subtitle-1 mine-shaft--text"
>
Last 7 days
</v-btn>
</div>
<div class="py-1">
<v-btn
plain
class="text-capitalize text-subtitle-1 mine-shaft--text"
>
Last 30 days
</v-btn>
</div>
<div class="py-1">
<v-btn
plain
class="text-capitalize text-subtitle-1 mine-shaft--text"
>
Last 90 days
</v-btn>
</div>
</div>
<span class="mx-2 mercury--bx-1"></span>
<div>
<v-date-picker
v-model="date"
#input="menu1 = false"
flat
no-title
color="lucky-point"
width="392"
/>
</div>
</div>
</v-card>
</v-menu>
</div>
</template>

show dialog box on mouseenter vuetify

I am trying to show a edit button and then open a dialog box on cliking using mouseenter and mouseleave. On entering the edit button is displayed but as soon as i click on it it's getting hide.
Can someone tell me what i am doing wrong here. The edit button is inside the DueDateAddM component.
<v-card-title class="mx-5">{{dayjs(key).format('DD MMM YYYY')}}</v-card-title>
<v-col v-for="(item, i) in value" :key="i">
<v-card-text
class="black--text py-0"
#mouseenter="item.isEdit=true"
#mouseleave="item.isEdit=false"
>
<v-row>
<span v-if="!item.isEdit" class="grey--text mr-1">#{{item.id}}</span>
<span
v-show="isLoggedIn"
v-if="item.isEdit"
class="mr-1"
#click="editDuedate"
>
<DuedateAddM :propItem="item" :duedateId="item.id" />
</span>
{{item.descp}}
<v-tooltip top>
<template v-slot:activator="{ on }">
<v-chip class="mx-1 py-0" small label v-on="on" v-if="item.previousdate">
<v-icon color="grey" small class="mr-1">fas fa-info-circle</v-icon>
<span>{{dayjs(item.previousdate).format("DD MMM YYYY")}}</span>
<span v-if="!item.previousdate">No Previous date found</span>
</v-chip>
</template>
<span>Previous Duedate</span>
</v-tooltip>
<v-tooltip top>
<template v-slot:activator="{ on }">
<v-chip small v-on="on" class="mx-1">
<v-icon color="grey" small class="mr-1">fas fa-tag</v-icon>
{{item.category}}
</v-chip>
</template>
<span>Category</span>
</v-tooltip>
<v-tooltip top>
<template v-slot:activator="{ on }">
<v-chip color="red lighten-4" small class="mx-1" v-on="on">
<v-icon color="grey" small class="mr-1">fas fa-map-marker-alt</v-icon>
{{item.region}}
</v-chip>
</template>
<span>Region</span>
</v-tooltip>
</v-row>
<v-row v-if="item.applicableto">
<v-subheader class="ml-1">Applicable To: "{{item.applicableto}}"</v-subheader>
</v-row>
<v-divider class="mt-2"></v-divider>
</v-card-text>
</v-col>
Use v-show instead of v-if
<span v-show="!item.isEdit" class="grey--text mr-1">#{{item.id}}</span>
<span
v-show="isLoggedIn"
v-show="item.isEdit"
class="mr-1"
#click="editDuedate"
>
<DuedateAddM :propItem="item" :duedateId="item.id" />
</span>

How to add right click event for v-treeview to open menu in vuetify?

I want to add right click event for v-treeview to open menu but I fail. I created a version that can open menu when left click and the main code is
<v-treeview v-model="tree" :open="open" :items="items" activatable item-key="name" >
<template v-slot:label="{item, open, selected}">
<v-menu
:value="showMenu"
>
<template v-slot:activator="{ on }">
<v-btn
flat
:ripple="false"
class="ma-0 pa-0"
v-on="on"
>
<!--button icon-->
<v-icon v-if="!item.file">
{{ open ? 'mdi-folder-open' : 'mdi-folder' }}
</v-icon>
<v-icon v-else>
{{ files[item.file] }}
</v-icon>
<!--button text-->
{{item.name}}
</v-btn>
</template>
<v-list>
<v-list-tile v-for="menuItem in menuItems" :key="menuItem">
<v-list-tile-title>{{menuItem}}</v-list-tile-title>
</v-list-tile>
</v-list>
</v-menu>
</template>
</v-treeview>
Note: the source code can be run at https://codepen.io/lhuangjs/pen/axMpYJ
And I am confused with v-on="on" in activator slot so much and I get some info from https://github.com/vuetifyjs/vuetify/issues/6866. However I still cannot understand it. Is there any more clear explanation?
thanks!
You have to use #contextmenu on the tree nodes.
I have tried to achieve what you tried. https://codepen.io/anon/pen/QPoYOQ?editors=1010#anon-login
But to make the tree look good, you have to do some CSS adjustments. I'm not sure any element other than v-btn or v-card accepts the #contextmenu event handler.
<div id="app">
<v-app id="inspire">
<v-treeview v-model="tree" :open="open" :items="items" activatable item-key="name">
<template v-slot:label="{item, open, selected}">
<v-btn flat #contextmenu="show">
<!--button icon-->
<v-icon v-if="!item.file">
{{ open ? 'mdi-folder-open' : 'mdi-folder' }}
</v-icon>
<v-icon v-else>
{{ files[item.file] }}
</v-icon>
<!--button text-->
{{item.name}}
</v-btn>
</template>
</v-treeview>
<v-menu v-model="showMenu" :position-x="x" :position-y="y" absolute offset-y>
<v-list>
<v-list-tile v-for="menuItem in menuItems" :key="menuItem" #click="clickAction">
<v-list-tile-title>{{menuItem}}</v-list-tile-title>
</v-list-tile>
</v-list>
</v-menu>
</v-app>
</div>
you can popup a context menu by adding #contextmenu event in a label slot:
<v-treeview :items="files" dense open-on-click transition hoverable>
<template v-slot:prepend="{ item, open }">
<v-icon v-if="item.children">{{ open ? 'mdi-folder-open' : 'mdi-folder' }}</v-icon>
<v-icon v-else>{{ icon(item.basename) }}</v-icon>
</template>
<template v-slot:label="{ item }">
<div #contextmenu.prevent="right($event, item)">{{ item.basename }}</div>
</template>
</v-treeview>