Comments (4)
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.
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.
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.
@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)
- [BUG] Tooltip shows briefly when using delayShow and moving to directly adjacent element HOT 3
- [FEAT REQ] Render tooltips inside portal HOT 4
- [BUG] CSP breaks, styles are injected even after disableStyleInjection is used HOT 2
- The component doesn't show the tooltip when there is a single quote " ' " in the data-tooltip-id and the id passed on the Tooltip component. HOT 2
- Safari mobile browser gets the error e.getAttributeNames HOT 2
- [BUG] : When ' (single quote) is used any where in the text, the tooltip doesn't open HOT 4
- I have set opacity to 1 but I can still see though HOT 3
- [BUG] HOT 2
- [BUG] #1042 Regression from 5.26.0 → 5.26.1 HOT 1
- Tooltip is not working HOT 2
- [BUG] Element with id 'react-tooltip-base-styles' already exists
- if message is long, how to make message's tooltip showing next to chat box HOT 5
- The tooltip is hidden by the parent tag using overflow-auto HOT 1
- [BUG] Anchor element doesn't open tooltip until re-render HOT 3
- Memory leaks: too many detached nodes HOT 1
- After changing the arrow position, there are already resolutions where the arrow does not appear in the right position (Any workaround handle this problem?) HOT 7
- Tooltip not working properly adding CSP HOT 1
- Nested elements with tooltip HOT 5
- [BUG] Flickering on tooltip after click on content inside HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-tooltip.