vue-context icon indicating copy to clipboard operation
vue-context copied to clipboard

Contextmenu won't close after open another one

Open pa4ul opened this issue 5 years ago • 4 comments

Hello!

I'm stuck on working with the vue-context. I don't know if it is a bug or if i wrote something false, if i open one contextmenu everything happens fine but if i start opening another one the first one opened should normally close automatically but in my case now both are opened.

Is it supposed to work like this? If yes, how can i achieve that only one is opened?

Thanks 👍

pa4ul avatar Sep 19 '20 13:09 pa4ul

@pa4ul I am not a contributor to this project, but I can maybe give you some half decent advice. I was able to get around this limitation by closing the context menu via a mouseleave event on the parent element. For something like a card list, this did the trick.

<article 
   @contextmenu.prevent="$refs.contextmenu.open"
   @mouseleave.prevent="$refs.contextmenu.close"
>
    <VueContext ref="contextmenu>...</VueContext>
</article>

alectrocute avatar Oct 01 '20 15:10 alectrocute

@rawilk Any input?

alectrocute avatar Oct 01 '20 15:10 alectrocute

I'm not sure, as I've never really dealt with that kind of scenario. Whenever I've used it in an app, I've only needed one instance of the context menu at a time.

However, it does do this behavior that you're describing on the demo pages in the docs since I'm using more than one instance there. I'm not really sure of a good solution to that, but what @alectrocute provided seems to work, I'd recommend using that.

rawilk avatar Oct 07 '20 12:10 rawilk

Hello, I had the same problem and for my situation I found a satisfactory solution.

In my case I am creating a treeview, so the vue-context was instantiated numerous times. Following the same idea of @alectrocute , I created a <div> that takes the vue-context plus the element and it applies @ mouseleave.prevent =" $ refs.menu.close ".

image01

image02

Along with this, I applied a class .menu-context-container that passes apadding: 0.1px;. Therefore, when exiting the element with the mouse, the vue-context will automatically close.

Hope this helps. :smile::v:

MatheusFr27 avatar Jan 07 '21 14:01 MatheusFr27