Skip to content Skip to sidebar Skip to footer

How To Close Outer V-tooltip On Inner V-tooltip Hover

I have two tooltips, one is on an outer element, the other on the inner element like this: How do I remove the outer tooltip when the inner tooltip is showing? Here's a Fiddle The

Solution 1:

You could fix this issue by using the stop modifier when handling the mouseoverevent, and add a boolean property called isOpen to show/hode the outer tooltip.

the stop modifier will prevent the event propagation

console.clear()

newVue({
  el: '#app',
  data: {
    isOpen: false,
    message: 'Outer Tooltip'

  }
})
body {
  font-family: sans-serif;
  margin: 42px;
}

.tooltip {
  display: block !important;
  z-index: 10000;
}

.tooltip.tooltip-inner {
  background: black;
  color: white;
  border-radius: 16px;
  padding: 5px10px4px;
}

.tooltip.tooltip-arrow {
  width: 0;
  height: 0;
  border-style: solid;
  position: absolute;
  margin: 5px;
  border-color: black;
}

.tooltip[x-placement^="top"] {
  margin-bottom: 5px;
}

.tooltip[x-placement^="top"].tooltip-arrow {
  border-width: 5px5px05px;
  border-left-color: transparent !important;
  border-right-color: transparent !important;
  border-bottom-color: transparent !important;
  bottom: -5px;
  left: calc(50% - 5px);
  margin-top: 0;
  margin-bottom: 0;
}

.tooltip[x-placement^="bottom"] {
  margin-top: 5px;
}

.tooltip[x-placement^="bottom"].tooltip-arrow {
  border-width: 05px5px5px;
  border-left-color: transparent !important;
  border-right-color: transparent !important;
  border-top-color: transparent !important;
  top: -5px;
  left: calc(50% - 5px);
  margin-top: 0;
  margin-bottom: 0;
}

.tooltip[x-placement^="right"] {
  margin-left: 5px;
}

.tooltip[x-placement^="right"].tooltip-arrow {
  border-width: 5px5px5px0;
  border-left-color: transparent !important;
  border-top-color: transparent !important;
  border-bottom-color: transparent !important;
  left: -5px;
  top: calc(50% - 5px);
  margin-left: 0;
  margin-right: 0;
}

.tooltip[x-placement^="left"] {
  margin-right: 5px;
}

.tooltip[x-placement^="left"].tooltip-arrow {
  border-width: 5px05px5px;
  border-top-color: transparent !important;
  border-right-color: transparent !important;
  border-bottom-color: transparent !important;
  right: -5px;
  top: calc(50% - 5px);
  margin-left: 0;
  margin-right: 0;
}

.tooltip[aria-hidden='true'] {
  visibility: hidden;
  opacity: 0;
  transition: opacity .15s, visibility .15s;
}

.tooltip[aria-hidden='false'] {
  visibility: visible;
  opacity: 1;
  transition: opacity .15s;
}

.box {
  border: 1px solid red;
  border-radius: 2px;
  padding: 15px;
  margin: 20px;
  text-align: center;
  cursor: pointer;
}

.box:hover {
  box-shadow: 004px;
}
<scriptsrc="https://unpkg.com/popper.js"></script><scriptsrc="https://unpkg.com/vue/dist/vue.js"></script><scriptsrc="https://unpkg.com/v-tooltip"></script><divid="app"><divv-tooltip="{content: message,
    show: isOpen}"class="box" @mouseover.stop="isOpen=true">
    {{ message }}
    <divv-tooltip="'Inner tooltip'" @mouseover.stop="isOpen=false"class="box">
      okokok
    </div></div></div>

Post a Comment for "How To Close Outer V-tooltip On Inner V-tooltip Hover"