Comments (5)
This will depend heavily on your design decisions. My first suggestion is to use the place
option with left-end
(see the docs for more info). This should improve the tooltip placement a bit (it will still move around when you scroll on a long message).
On another note, if I'm not mistaken, you're using tooltip components for each anchor element, so you might want to check this section on our troubleshooting page.
https://react-tooltip.com/docs/troubleshooting#dynamically-generated-anchor-elements
This video doesn't capture it super well, but I'm noticing a "rogue" tooltip showing up randomly when hovering/unhovering on elements that have a tooltip. You might be able to test this yourself.
tooltip.mp4
Using multiple tooltip components isn't the cause of this bug, but using a single tooltip for your whole application (or at least only a handful) helps mitigating these kinds of bugs.
from react-tooltip.
There's definitely a way to achieve what you're trying, it's just not so obvious to me right now how to do it.
I'll have to come back to this when I have the time, might be able to suggest something. Let me know if you figure out anything.
from react-tooltip.
This is a very hard thing to accomplish due to how the tooltip works internally. The best I could come up with is the following example:
https://stackblitz.com/edit/vitejs-vite-fsaxej?file=src%2FApp.tsx
The main thing here is to keep the tooltip inside the scrollable element (the chat box in your case), and add position: relative
to it, so the tooltip stays inside it.
You also need to override the default floating-ui
middlewares.
import { offset, flip, shift } from '@floating-ui/dom';
<Tooltip middlewares={[offset(10), flip(), shift({ padding: 300 })]} />
(padding: 300
on the shift
middleware is roughly half the height of the scrollable element on the example, you may need to play around with the value to get the tooltip to stay centered on the chat box)
Still, you'll run into the issue of the tooltip getting clipped if the container is not wide enough.
As I've said before, it's definitely doable, but pretty hard to achieve due to how react-tooltip
works.
I'll keep this open for now if you want to share any findings, but I'd suggest trying a different approach for displaying the tooltip on the messages.
And by the way, I've given the suggestion of using less tooltip components (https://react-tooltip.com/docs/troubleshooting#dynamically-generated-anchor-elements), but if you choose to follow something like this example I've linked here, you'll definitely want a separate tooltip specifically for the chat messages, since you'll be overriding default behavior.
from react-tooltip.
-
("rogue" tooltip showing up randomly), checked troubleshot link, thanks, it will fix the problem.
-
data-tooltip-place is not working for us, when user scroll down we see tooltip showing far from the bottom of chat screen, ( chats don't open always on bottom of screen), like in the screen shot bellow. ideally the tooltip should appear always near to the chat screen area (bellow screen shot red box)
from react-tooltip.
Related Issues (20)
- [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 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
- The tooltip is hidden by the parent tag using overflow-auto 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.