Open morficus opened 4 years ago
also can easily be done by
@contextmenu.prevent="on.click"
in activator slot, or @contextmenu.prevent="vmodelProp = true"
on a non-activator slot button.
eg: https://codepen.io/majesticpotatoe-the-bashful/pen/MWWWWjR
ah that is great to know.
there is still the issue of the ClickOutside
directive not having support for the oncontextmenu
event. Let me know if I should open a bug for that - https://codepen.io/morficus/pen/QWWWWdZ
You can use both right click and left click on the same button with @MajesticPotatoe 's suggestion above. Just use @contextmenu.prevent="on.click"
to show the menu on right-click and a @click
to use the click as usual.
I found this helpful to have a 'default' one-click behaviour and a menu on right-click.
I think having official support for a contextmenu (or auxclick) variant would be much better than remapping the click action to oncontextmenu
.
Currently, there is no support for oncontextmenu events outside the menu, so all the menus you open stay open, with high chance of overlap unless you build a higher-level watcher that closes any other menus if you open a new one, or use a single menu in a parent container that receives arguments from the underlying list items, which is a very different flow from regular v-menu usage.
Additionally, using oncontextmenu
on an element which already has the menu opened, I'd expect the menu to translate to the new cursor location, instead of closing (and then having to open it again), while with a click event (outside or not), the closing iof the menu is expected.
I think with a v-menu-context component, extended from v-menu with its own definition for oncontextmenu
and a redefinition for the clickhandler, (or hidden behind the open-on-contextmenu prop) a lot of these issues could be taken away.
Problem to solve
Currently the VMenu component can be opened either with a click-event (default) or on hover (configurable via a prop). A common use case (especially for large or "enterprise-class" applications) is to have a custom context menu which is invoked via a right-click. As things stand today, VMenu does not handle this out of the box.
Proposed solution
Create a new prop to VMenu called
open-on-right-click
oropen-on-contextmenu
(with a default value of false) which would behave the same asopen-on-hover
andopen-on-click
.This would also involve updating the ClickOutside directive to handle both the
onclick
as well as theoncontextmenu
events.