Giter Site home page Giter Site logo

Comments (4)

danny-does-stuff avatar danny-does-stuff commented on June 11, 2024 1

Resolved! The main problem was that my button only had an SVG icon inside, so the click to close the tooltip was getting captured by the SVG. I fixed that by just adding pointer-events: none; to the SVG. Closing the tooltip works fine if the child of the button is just some text. I don't know whether there's anything react-tooltip can do to fix this issue with SVGs.

To get close on click to work, you have to use the props openOnClick and closeEvents={{ click: true }}. Here is a code sandbox

from react-tooltip.

gabrieljablonski avatar gabrieljablonski commented on June 11, 2024

The intended behavior for openOnClick is for it to just open on click. When using just that prop, the tooltip will only close when clicking outside the anchor.

The correct way to achieve the behavior you want, as you've pointed out, is to use openEvents={{ click: true }} (or simply openOnClick, though openEvents is preferred in this case) alongside closeEvents={{ click: true }}.

This name for openOnClick might be a little misleading, so we'll consider updating the docs to explain that.

Now for the behavior with an SVG, we'll take a look at it later and see if there's anything viable we can do directly with the tooltip.

from react-tooltip.

gabrieljablonski avatar gabrieljablonski commented on June 11, 2024

Apparently it's a known issue with using SVGs.

c7f865f adds a section on the troubleshooting page about it. Should be live on the docs soon.

from react-tooltip.

rodrigofsouto avatar rodrigofsouto commented on June 11, 2024

@gabrieljablonski @rodrigofsouto

I think it's more than that... it seems the click event is not propagating to the tooltip container.

Here is my Tooltip definition:

<Tooltip openEvents={{focus:true, mouseenter:true}} 
      closeEvents={{blur:true, mouseleave:true, click:true}} 
      id='mytt'/>

If I have a <MyButton /> component that returns something like this:

<div id='wrapper' data-tooltip-id='mytt' data-tooltip-content='testing...'>  
  <button id='button' type='button'>
    <span id='text'>Click here!</span>
  </button>
</div>

The click event on the MyButton component does not close the tooltip. Even if I move data-tooltip-id and data-tooltip-content to the button element, it still doesn't work. It only works if I move them to the text element.

from react-tooltip.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.