Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there anyway to close the popover while clicking any content of the popover? #116

Closed
Guobacai opened this issue Sep 5, 2019 · 13 comments

Comments

@Guobacai
Copy link

Guobacai commented Sep 5, 2019

Method "handleDocumentClick" won't set the "showPopper" to false if user clicks any content in the popover "e.target".
Is there any recommended way to do so?
If not, would that be a good feature?

@RobinCK
Copy link
Owner

RobinCK commented Sep 6, 2019

Please provide more details.

@greyphilosophy
Copy link

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.

@huanglvming
Copy link

anyone to answer this question?

@greyphilosophy
Copy link

greyphilosophy commented Sep 19, 2019

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!

@huanglvming
Copy link

@RobinCK come and fix the issue

@RobinCK
Copy link
Owner

RobinCK commented Sep 23, 2019

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

@greyphilosophy
Copy link

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

@RobinCK
Copy link
Owner

RobinCK commented Sep 24, 2019

please jsfiddle example

@greyphilosophy
Copy link

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

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

@jonnedeprez
Copy link

jonnedeprez commented Sep 24, 2019

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

@huanglvming
Copy link

huanglvming commented Sep 25, 2019 via email

@greyphilosophy
Copy link

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

@huanglvming
Copy link

huanglvming commented Sep 25, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants