Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Popover not closing when clicking outside its focus area

I'm using Bootstrap Vue with Vue.js and am experiencing a problem where I'm iterating over some items and displaying them to the user.

The issue is, when a user clicks on one of the popovers, every popover that was opened gets closed (as I desire), but when the user clicks outside the focus area of the targeted (opened) popover, it doesn't close anymore.

It looks like the opening animation runs every time the user clicks on the targeted popover.

Here is the code:

<template>
  <div>
    <div class="row" v-for="(n, i) in 5" :key="n">
      <div :id="'popover' + visitor.id + '-' + i" @click="$root.$emit('bv::hide::popover')">
        <div class="card">
          <b-popover :target="'popover' + visitor.id + '-' + i">
            <template slot="title">
              Edit image
              <button
                class="close-popover"
                @click="$root.$emit('bv::hide::popover', 'popover' + visitor.id + '-' + i)"
              >X</button>
            </template>
          </b-popover>
        </div>
      </div>
    </div>
  </div>
</template>

Any help is appreciated!

like image 412
hakaman Avatar asked Nov 22 '25 14:11

hakaman


1 Answers

You can set triggers="click blur" on the popover. This will close it when the user clicks outside of the popover or on the target.

You can check more HERE.

like image 126
Vedran Avatar answered Nov 24 '25 04:11

Vedran



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!