Skip to content

Commit bc3657c

Browse files
docs: troubleshooting scrolling issues
1 parent fac0216 commit bc3657c

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

docs/docs/troubleshooting.mdx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,42 @@ If you've imported the default styling and the tooltip is still not showing up w
6464

6565
If `data-tooltip-content` and `data-tooltip-html` are both unset (or they have empty values) on the anchor element, and also the `content`, `render`, and `children` props on the tooltip are unset (or have empty values), the tooltip is not shown by default.
6666

67+
68+
## The tooltip doesn't move when scrolling
69+
70+
If your anchor element is inside a scrolling element, your tooltip might get "stuck" in place when scrolling.
71+
There are two ways to avoid this.
72+
73+
74+
### Change your CSS (recommended)
75+
76+
For the tooltip to be properly placed inside a scrolling element, the following conditions must be met:
77+
78+
1. The tooltip component has to be inside the scrolling element (placing it as a direct child is **not** required)
79+
2. The `positionStrategy` tooltip prop must be unset, or set to the default (`absolute`)
80+
3. The scrolling element should have the CSS attribute `position: relative`
81+
82+
:::info
83+
84+
The `position: relative` attribute can be set on any element on the DOM structure between the scrolling element and the tooltip.
85+
This means the tooltip component doesn't have to be a direct child of the scrolling element.
86+
87+
:::
88+
89+
### Use `closeOnEsc` prop
90+
91+
```tsx
92+
<Tooltip closeOnEsc={true} />
93+
```
94+
95+
When `closeOnEsc` is set, scrolling will immediately close the tooltip (`closeOnResize` also exists for closing when resizing the window).
96+
97+
:::caution
98+
99+
For this to work properly, the scrolling element must either be the root `html` tag, the tooltip parent element, or the anchor parent element.
100+
101+
:::
102+
67103
## Bad performance
68104

69105
If you're experiencing any kind of unexpected behavior or bad performance on your application when using ReactTooltip, here are a few things you can try.

0 commit comments

Comments
 (0)