Giter Site home page Giter Site logo

Remove 'trigger' requirement about vue-popper HOT 7 OPEN

robinck avatar robinck commented on May 15, 2024 8
Remove 'trigger' requirement

from vue-popper.

Comments (7)

bagelbyte avatar bagelbyte commented on May 15, 2024 8

sure! I use something that looks like this:

<template>
    <div>
        <popper ref="popper" :force-show="showPopper">
            <div class="popover">
                <h1>wazam</h1>
            </div>

            <div slot="reference">
                <h1>shazam</h1>
            </div>
        </popper>    
        <button @click="openPopper">openpopper</button>
    </div>
</template>
<script>
import Popper from 'vue-popperjs'

export default {
    created(){

    },
    components: {
        Popper
    },
    methods: {
        openPopper(){
	    this.showPopper = !this.showPopper
        }
    },
    data(){
        return {
            showPopper: false
        }
    }
}
</script>

But with the configurations as shown above, the popover still appears on hover. I CAN get around it by setting the 'delay-on-mouse-out' and 'delay-on-mouse-over' values to something very large, where hover/clicks effectively are useless and it just opens with the force-show being toggled, but I figure it was better just to bring it up

from vue-popper.

geongeorge avatar geongeorge commented on May 15, 2024 4

I have edited your solution to get rid the trigger issue,

Add popper to a dummy div under (or above) the target element.
If the div has zero height, it won't be clickable
You can use 'force-show' prop to toggle it

<h1>shazam</h1>  
<popper ref="popper" :force-show="showPopper">
            <div class="popover">
                <h1>wazam</h1>
            </div>
          <div slot="reference">
                <div></div> <!-- Basically empty -->
            </div>
 </popper>    

<button @click="openPopper">openpopper</button>

from vue-popper.

vq0599 avatar vq0599 commented on May 15, 2024 1

if 'force-show ' was used , don't listener trigger events.

mounted() {
        this.referenceElm = this.reference || this.$slots.reference[0].elm;
        this.popper = this.$slots.default[0].elm;

        // add next line
        if (typeof this.forceShow === 'boolean') return
        

        switch (this.trigger) {
            // ...
        }
    },

It's solution ?

from vue-popper.

devWaleed avatar devWaleed commented on May 15, 2024

@bagelbyte Can you share how you're using force-show to enable tooltip?

from vue-popper.

generator85 avatar generator85 commented on May 15, 2024

This would be very useful, can I add that it would be great if the document-click event would still be fired when no trigger is given.

from vue-popper.

TurboControl avatar TurboControl commented on May 15, 2024

Thanks bagelbyte and geongeorge. The reason why I need to use this type of programming method is because I have interactive components inside the popper and if they effectively make the HTML reactive, the popper gets dismissed. I tried to use click.prevent, but that didn't help. It would stop the popper from dismissing, but only if there was a non-reactive change.

I do have success with dynamic reactivity (loading spinner -> show data), but specifically when I insert rows into a table or toggle a row's visibility, the popper dismisses and without error. Using force-show works around this problem.

The side effect of all of this is that the user can no longer dismiss the popper by clicking outside of the popper. They now need to toggle or use a close button. Is there a way I can gain that feature back? Like emit an event clickOutside?

from vue-popper.

karakum avatar karakum commented on May 15, 2024

And what about simultaneously hover&click handlers for touch&desktop. On desktop 'hover' used, on mobile - 'click' used...
Now I set 'hover' type and listen @click to toggle popper 'programmatically'

from vue-popper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.