Giter Site home page Giter Site logo

Comments (13)

greyphilosophy avatar greyphilosophy commented on May 14, 2024 5

We are running into this issue too. Inside the popover we have several buttons. When a user clicks one of those buttons we would like the popover to close.

from vue-popper.

jonnedeprez avatar jonnedeprez commented on May 14, 2024 1

I solved programmatic closing of popper like this:
https://jsfiddle.net/jonnedeprez/mtk0npbo/

from vue-popper.

RobinCK avatar RobinCK commented on May 14, 2024

Please provide more details.

from vue-popper.

huanglvming avatar huanglvming commented on May 14, 2024

anyone to answer this question?

from vue-popper.

greyphilosophy avatar greyphilosophy commented on May 14, 2024

What we ended up doing is putting an @blur on the button that opens the popover. That way any click anywhere will close it. But it closes faster than clicks on the popover can be recognized so we put a delay on it to give time for the click to hit the menu button. In our case we have a table of users, and we use the userID to identify which popover belongs to which row.

<popper
    :force-show="showPopper.includes(member.userID)"
    trigger="click"
>
    <div class="popper">
        <button
            class="menu"
            @click="doSomething(member.userID)"
        >
    </div>
    <div slot="reference"/>
</popper>
<button
    class="action-dots"
    @click="openPopper(member.userID)"
    @blur="slowClose()"
>

Because someone can click from one popover to another we could potentially, for a split second, have two popovers open at once. So we keep track of which ones should be shown in an array.

data() {
    return {
      showPopper: []
    }
}

And our methods look like this:

methods: {
    openPopper(popperId) {
      this.showPopper.includes(popperId) ? this.showPopper = [] : this.showPopper.push(popperId);
    },
    slowClose() {
      _.delay(() => { this.showPopper.shift() }, 200);
    },
}

The ternary is in there because two clicks on the same button should close the popover.

This feels a lot like a hack, so if anyone else has a better solution please share!

from vue-popper.

huanglvming avatar huanglvming commented on May 14, 2024

@RobinCK come and fix the issue

from vue-popper.

RobinCK avatar RobinCK commented on May 14, 2024

Пожалуйста посмотрите похожую проблему #114

from vue-popper.

greyphilosophy avatar greyphilosophy commented on May 14, 2024

#114 helps, but I still run into the problem of the popover closing faster than the click on the button inside it being registered.

from vue-popper.

RobinCK avatar RobinCK commented on May 14, 2024

please jsfiddle example

from vue-popper.

greyphilosophy avatar greyphilosophy commented on May 14, 2024

@RobinCK спасибо, что заглянули в это

https://jsfiddle.net/greyphilosophy/v0joqcL3/9/

from vue-popper.

huanglvming avatar huanglvming commented on May 14, 2024

from vue-popper.

greyphilosophy avatar greyphilosophy commented on May 14, 2024

@huanglvming it's part of the vue-popper. You can search for it to find where it is defined.

from vue-popper.

huanglvming avatar huanglvming commented on May 14, 2024

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.