Comments (7)
Hi, just use tooltip as a controlled component.
Here's a rough example of how you can implement required behavior https://codesandbox.io/s/mm3klvjjjx
Use tab to switch the focus between buttons. When you focus on the middle button, tooltip shows. When the button lost the focus, it hides.
You can use tooltipShown
and onVisibilityChange
to control the appearance of the tooltip from the outside. See README and controlled example.
from react-popper-tooltip.
@robertkraig Here's quick rewrite with react class component https://codesandbox.io/s/jj3rm0nnmw
from react-popper-tooltip.
@mohsinulhaq that was exactly what I needed to see. Wish the docs where as clear as this example was.
from react-popper-tooltip.
@robertkraig I hope the solution worked out for your use case :)
from react-popper-tooltip.
@mohsinulhaq absolutely. I had to 1st figure out though how the whole useState stuff worked so I understood your example. I think it's still a little too pre-mature for production-level usage of useState. I know it's been out for a minute, but most people don't have the right version of react yet. Only the bleeding edge people use it atm.
from react-popper-tooltip.
@robertkraig I like hooks and use them in my everyday work. That's the reason why I used useState
. Just because it was easier for me to prepare a quick proof of concept. You can use any state management as you want - setState, redux, recompose's useStateHandler, react-powerplug's container. It's totally up to you.
from react-popper-tooltip.
@robertkraig please confirm if the solution sufficed so that we can close this issue
from react-popper-tooltip.
Related Issues (20)
- display: none on tooltip arrow HOT 2
- Version 4.X.X isn't supported in Shadow DOM. HOT 7
- Tooltip does not disappear when fast hovering over multiple setTriggerRef divs. HOT 10
- Keep tooltip open on mousedown/up and etc when trigger='click' and interactive=true HOT 1
- Unable to stop propogation in react-tooltip HOT 4
- Type check error with Typescript 4.4 exactOptionalPropertyTypes HOT 5
- `getTriggerRef` invoking with null HOT 1
- react-popper-tooltip has no exported member "usePopperTooltip" HOT 1
- Typescript error when using `getTooltipProps` in a div HOT 3
- don't close on losing hover HOT 5
- Handling focus outside
- Focus + interactive HOT 2
- Horizontal scrollbar appears, tooltip is cropped HOT 2
- React testing library hover event not triggered when trigger text if wrapper with additional element HOT 2
- Is not possible to pass a strategy HOT 4
- floating-ui version of the lib HOT 1
- Custom styles for "tooltip-container" HOT 1
- Can't disable preventOverflow modifier
- Placement is not working properly in tables HOT 6
- Support for newer versions of react
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-popper-tooltip.