Tippyjs: Feature request: Close any open tooltips when opening a new one

Created on 9 Jul 2018  路  3Comments  路  Source: atomiks/tippyjs

I have a few tooltips in some text that are interactive. They have delays on closing to make them less likely to accidentally close when you try to interact with them.

The problem is when you skip to another tooltip, the previous tooltip remains open due to the delay. If I skip over a few quickly, it creates a big mess of overlapping tooltips. It would be nice if Tippy could close all the other tooltips when I open a new tooltip.

This is kinda related to #81, but for closing delay instead of opening delay.

馃拵 enhancement

Most helpful comment

v4's .hideAll() method makes this simpler:

tippy(ref, {
  onShow(instance) {
    tippy.hideAll({ exclude: instance })
  }
})

All 3 comments

For now you can implement custom logic

tippy(ref, {
  onShow(instance) {
    document.querySelectorAll('.tippy-popper').forEach(popper => {
      if (popper !== instance.popper) {
        popper._tippy.hide()
      }
    })
  }
})

@atomiks Nice, thanks!

v4's .hideAll() method makes this simpler:

tippy(ref, {
  onShow(instance) {
    tippy.hideAll({ exclude: instance })
  }
})
Was this page helpful?
0 / 5 - 0 ratings

Related issues

divmgl picture divmgl  路  3Comments

khanamiryan picture khanamiryan  路  5Comments

KubaJastrz picture KubaJastrz  路  3Comments

Christian24 picture Christian24  路  3Comments

faroukcharkas picture faroukcharkas  路  4Comments