vue-click-away icon indicating copy to clipboard operation
vue-click-away copied to clipboard

Elements with a v-if tag are not evaluated as a descendant.

Open astarrh opened this issue 3 years ago • 5 comments

It seems that anything located in or beneath an element using v-if is disqualified from inheritance.

    <div v-click-away="doAction"> 

        <div id="worksFine">
              DivContent
        </div>

        <div id='disqualified' v-if="someFlag === true">
            This still triggers "doAction" (even with someFlag set to true)
        </div>

    </div>

This was happening in my custom directive as well. It seems that v-if breaks .contains() in some way.

astarrh avatar Jun 20 '21 16:06 astarrh

We had the same issue, we found the work around by using v-show instead of v-if tags

aralzaim7 avatar Jul 23 '21 17:07 aralzaim7

@astarrh @aralzaim7 Can you try removing this return and see if that works

https://github.com/VinceG/vue-click-away/blob/master/index.js#L37

VinceG avatar Jul 23 '21 17:07 VinceG

@VinceG Sorry, I'm having trouble replicating this issue now. The example I pasted is working fine for me when I try to re-implement it.

astarrh avatar Jul 23 '21 18:07 astarrh

@VinceG I ran into this same issue. I removed the return as you suggested and it seems to work as expected now.

TheAustinG avatar Sep 24 '21 19:09 TheAustinG

It can be solved by

<div
        v-click-away="closeSomething"
        @click.stop
    >
    <div v-if="someThing"></div>
</div>

Or use v-show

soloviofff avatar Oct 08 '21 12:10 soloviofff