Comments (7)
That's good to know. I'm considering adding a section on our documentation covering more clearly (and with examples like this) how to use different middlewares.
Though this isn't a huge issue, since most users are completely fine with just the default behavior, so something to get to eventually.
from react-tooltip.
The most "natural" way to do this in V5 would be to use floating-ui
's middlewares options to achieve your second suggestion.
have the tooltip ignore its place directive, e.g. if I set place="left" and it doesn't fit on the left or right, have it go to top/bottom if one of those would fit it on screen
As you've pointed out, it already does it for same-axis overflow (left switches to right if no space left, top to bottom, and so on) with the flip()
middleware, but it indeed doesn't happen cross-axis (e.g. left to bottom).
This is kind of a weird situation to "fix", since different use-cases would call for different solutions (for example, your "squish" suggestion is totally valid in some cases), but since we already do the left<->right/top<->bottom flip, I don't see why not do this one as well.
See fallbackAxisSideDirection
if you're interested in the details (here's also how you'd go about it using the middlewares
tooltip prop), but [email protected]
offers the cross-axis flip behavior by default.
from react-tooltip.
Thanks for your reply, this looks very helpful. I'll give this a try and report back (and close the issue) once I figure out what middleware fits my use case.
from react-tooltip.
We'll close the issue once #1140 gets merged. Just let us know if it works properly, or if you have other suggestions about this.
from react-tooltip.
Hm okay. I think I still want the "squish" behavior even with the fallbackAxisSideDirection
setting, so I arrived at a hybrid that uses flip()
plus size
with a minimum width to accomplish a best-fit "squish", then a flip
with the fallback axis to have it as a fallback when the best-fit doesn't do the trick. https://codesandbox.io/p/sandbox/react-tooltip-overflow-forked-pjz72c
middlewares={[
offset(10),
flip(),
size({
apply: ({ availableWidth, availableHeight, elements }) => {
Object.assign(elements.floating.style, {
maxWidth: `${Math.max(200, availableWidth - 50)}px`,
});
},
}),
shift({ padding: 5 }),
flip({
fallbackAxisSideDirection: "start",
}),
]}
(I'm not sure why the -50
in the maxWidth
expression was so important. At first, my goal was to set a margin away from the edge of the window, but small values like -10
or even -30
didn't seem to have an effect.)
from react-tooltip.
Official release [email protected]
fixes this and some other stuff.
from react-tooltip.
Some of tooltips are too large to fit on a single line, so I want them wrapped (instead of clipped). @dylemma's snippet helped me, thanks!
I understand that 5.25.1 improved something in the area, but it didn't seem to help with the wrapping. Perhaps that too could be added to the default behavior?
from react-tooltip.
Related Issues (20)
- [BUG] When using default rt-transition-show-delay, tooltip stays in DOM after visibly closing HOT 13
- [BUG] Infinite rerender loop when tooltip is open for an anchor that is inside a scrolled overflow HOT 2
- [BUG] "mousemove" is not working on drag but "pointermove" event will work HOT 9
- [BUG] Strings are not escaped properly HOT 2
- [BUG] when i zoom out or in the big screen resolutions the tooltip is not in right place HOT 3
- Can't import the named export 'arrow' from non EcmaScript module (only default export is available) HOT 7
- [BUG] openEvents does not work with "click" HOT 4
- Is is possible to export default middlewares? HOT 1
- [BUG] Testing react-tooltip with modal result to a failed HOT 1
- [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] anchor element does not close the tooltip on click HOT 3
- [BUG] #1042 Regression from 5.26.0 → 5.26.1 HOT 1
- Tooltip is not working HOT 2
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.