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

How to close tooltip on second click or click away on mobile #60

Open
ErinPo opened this issue Feb 22, 2017 · 6 comments
Open

How to close tooltip on second click or click away on mobile #60

ErinPo opened this issue Feb 22, 2017 · 6 comments

Comments

@ErinPo
Copy link

ErinPo commented Feb 22, 2017

Even if it involves javascript, no problem...

@kazzkiq
Copy link
Owner

kazzkiq commented Feb 22, 2017

There is the data-balloon-visible attribute which lets you programatically show (or hide) tooltips. You could use JavaScript to enable/disable it on click with some approach like that:

function toggleTooltips(event) {
  var elem = event.target;
  var elemAttr = elem.getAttribute('data-balloon-visible');

  // If tooltip visible, hide it
  if(elemAttr && elemAttr !== "") {
    elem.removeAttribute('data-balloon-visible');

  // If tooltip hidden, make it visible
  } else {
    elem.addAttribute('data-balloon-visible');
  }
}

// Then call it on your elements (e.g.: with jQuery)
$('.toggle-tooltip').on('click', toggleTooltips);

@ErinPo
Copy link
Author

ErinPo commented Feb 22, 2017

This would allow for on/off behavior by clicking on the target, but would not hide it by clicking elsewhere to remove the focus, right? This difficulty to remove focus is specific to iOS.

@cthedot
Copy link

cthedot commented Oct 9, 2017

You could save the current visible balloon and close it when click on any other balloon element. This way at least there would be a single balloon visible at any time. Or simply close any balloon after a timeout of like 5 seconds? Handling a click somewhere else would IMHO be overkill but would be an option too.

@errantmind
Copy link

errantmind commented Feb 26, 2020

I am also unable to get around this issue in iOS 12.2 in both of the browsers I tested (Chrome and Safari). I am unable to 'click away' and therefore 'close' the balloon. This blocks other onClick events in my webapp, making this a major issue for me.

edit: I got around the issue by putting cursor: pointer to the relevant css

@moeenio
Copy link
Contributor

moeenio commented Apr 16, 2020

My solution to make focus lost when clicking outside something with iOS is to put an empty onclick on other elements, even though that's not ideal

@kristofzerbe
Copy link

The solution should be to avoid showing Balloon tooltips on touch devices, because there is no HOVER. A simple solution is to wrap the complete CSS in

@media (hover: hover) {
...
}

Repository owner deleted a comment from 19890843006 Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants