Tooltip doesn't stay anchored to element when scrolling
See original GitHub issueIssue Description
Tooltip doesn’t stay anchored to element when scrolling. Another way of phrasing it is that tooltip position doesn’t change relative to the window, even when scrolling.
Expected Behavior
If I scroll, tooltip should stay anchored to the element it first appeared on. If scrolling so much that the element significantly disappears from view, tooltip should naturally disappear with it.
Actual Behavior
Tooltip remains in a fixed position relative to the window.
When tooltip first appears:

Tooltips position when scrolling:

What I’ve tried
- Playing with styles such as “will-change” and “position” directly in Chrome devtools.
- Looking at the reactstrap tooltip documentation to see if there were any props that I could change which might help.
- Tried passing a prop from the Popper API
positionFixed={false}, but it doesn’t appear to be recognized by reactstrap:
index.js:2178 Warning: Received `false` for a non-boolean attribute `positionfixed`.
If you want to write it to the DOM, pass a string instead: positionfixed="false" or positionfixed={value.toString()}.
If you used to conditionally omit it with positionfixed={condition && value}, pass positionfixed={condition ? value : undefined} instead.
in div (created by Tooltip)
in div (created by Popper)
in Popper
Anything else that might help
Some source code:
import React, { Component } from 'react';
import { Button, UncontrolledTooltip } from 'reactstrap';
import { error } from '../../styles'
export class ButtonPrimary extends Component {
constructor(props) {
super(props);
this.continue = this.continue.bind(this);
this.state = {
tooltipOpen: false,
tooltipMessage: this.props.constraintMessage,
continueOk: this.props.continueOk
};
}
continue() {
if (!this.state.continueOk)
this.setState({tooltipOpen: true})
}
render() {
return (
<React.Fragment>
<Button style={this.props.style} color={'danger'} id='continue-button' onClick={(e) => {this.continue(e)}}>{this.props.children}</Button>
<UncontrolledTooltip
style={{paddingTop: '10px',
paddingBottom: '10px',
color: error,
fontWeight: 'bold'}}
placement={'bottom'}
isOpen={this.state.tooltipOpen}
target='continue-button'>
{this.state.tooltipMessage}
</UncontrolledTooltip>
</React.Fragment>
);
}
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
How can I fix the position of tooltips within a scrolling <div>?
When the tooltips are added, it appears to take the distance from the top of the table to the hovered cell, and draw...
Read more >Tooltip disappearing on scroll. | Blazor Forums - Syncfusion
Is it possible with the current tooltip to make the tooltip not dissapear and be correctly anchored to its element when scrolling the...
Read more >Tooltips - Bootstrap
The tooltip plugin generates content and markup on demand, and by default places tooltips after their trigger element. Trigger the tooltip via JavaScript:...
Read more >Tooltip Position Incorrect When Scrolled Down Page - Telerik
It seems to remain static where it is, and doesn't update based on where the ... show what element I'm hovering over to...
Read more >ARIA: tooltip role - Accessibility - MDN Web Docs - Mozilla
Tooltips provide contextual information about an element when that owning element receives focus or is hovered over, but is otherwise not ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Tooltips and Popover are positioned
absolutely,. so they’ remain relative to their scrollParent, Overlay assumes that’s thewindowbut if your app has a different scrollParent, you sohuld set it via thecontainerprop. See here for an example: https://react-bootstrap.github.io/components/popovers/#popovers-positioned-scrollingI should note that the latest version of react-bootstrap is still for v3 of bootstrap and so doesn’t use Popper.js
FWIW – I was able to fix this by simply adding
position: relativeto thebodytag in our application. The hint was taken from this S/O answer (but seems the magically have worked across our app with limited other impacts): https://stackoverflow.com/a/22606657/895641