atomiks / tippyjs

Tooltip, popover, dropdown, and menu library
https://atomiks.github.io/tippyjs/
MIT License
12.03k stars 520 forks source link

"Show" method to show/hide Tippys not working on browser "mousedown" events #926

Closed justsomeusername2020 closed 3 years ago

justsomeusername2020 commented 3 years ago

Description I have what's probably a pretty simple issue, but maybe its more complicated. So here goes..

On my webpage I wish to:

There's no Tippy prop that can replicate this behavior (correct me if I'm wrong), but I can achieve this by using a javascript function for mousedown events. (I played with the onClickOutside prop for bit, but I wish to assign the event action to any mouse button (left, middle, right).

Setup I'm using local Tippy CSS on my production webpage. But I've tried using the CDN CSS too, and the issue is present using both, so this issue is not CSS related.

Problem I'm having trouble forming the Tippy Instances correctly, so that the Tippy is displayed correctly using the instance.show() method.

Here's a JSFiddle with a demo of my issue: https://jsfiddle.net/playdohsniffer/3nkp7saz/42/

a) If you hover the mouse pointer over any fruit, the Tippy is shown correctly (on right side) as expected.

b) Also when hovering the mouse pointer over any fruit, there's an additional "odd-shaped arrow with no content" being created at the top.

Suspected root cause Lines 24, 25 in the Javascript I suspect are my problem. Do I have the wrong CSS selectors? How do I fix these? I'm unable to figure it out.

Many thanks in advance for advise...

justsomeusername2020 commented 3 years ago

Update: After reviewing a number of closed issues here, and seeing more complex examples of Tippy constructs (than what's shown in the user manual), I finally realized that in my Javascript, I errantly had the CSS selector separated from the Tippy construct, which was causing those extra, empty (odd-shaped) Tippys.

After combining them, its work perfectly.

const tip1 = tippy(document.querySelector('#apples') , { content: "<div><strong>Fruit Variety</strong></div><div>Red Delicious</div>", allowHTML: true, placement: 'right', trigger: 'manual', })