Comments (4)
I went ahead and wrote a custom tooltip component because like you said I was spending more time trying to make this work for our needs. Plus we needed it done for a big demo and this and several other things just made more sense to solve with a custom component. Plus we could better define style variations based on our branding spec which was a bit of a pain point too.
The demo looks like it would work, as long as it also works with selectors and such I think it's good.
from react-tooltip.
Per the comments in #1164 - you have two options I guess.
- Implement the portal logic yourself. Several libraries like blueprintjs do this, but it can be annoying to deal with when you have several libraries all with their own portals, especially if you need things to mix z-index-wise. That's not the case here, nothing should ever be above tooltips. You would use
createPortal
and render the tooltip to that so it's not rendered inside the react tree and this position: fixed is never subject to anything but the viewport. - Allow users to provide their own portal. For example I have a component called
Portal
that renders any children to our own react portal. So if there's a way to customize the tooltip renderer, I can render the tooltip as a child of that Portal component.
This is psuedo-code but maybe a render prop that gives me the tooltip you will render, but returns a ReactNode:
<Tooltip render={(Tooltip) => <Portal><Tooltip /></Portal>} />
from react-tooltip.
This is psuedo-code but maybe a render prop that gives me the tooltip you will render
Exposing the "pre-rendered" tooltip through the render
prop is quite an interesting idea. It might work as a placeholder until (or if) we start using portals internally.
Will try to work on this over the next few days whenever I have the time.
Thanks for the suggestion!
from react-tooltip.
Were you able to use the tooltip with your own portal?
As far as I can tell, with this simple example, it should work just fine with createPortal()
.
Can you provide a quick example similar to how the storybooks you mentioned work? So I can have some reference to the tooltip being misplaced.
We might try using portals internally for the next major version (not sure how viable that will be yet), but, as I've said, it'd be nice to have a ready-to-go example on how to do it manually for V5.
from react-tooltip.
Related Issues (20)
- [BUG] Tooltip shows briefly when using delayShow and moving to directly adjacent element HOT 3
- [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] anchor element does not close the tooltip on click HOT 4
- [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.