diff --git a/src/components/Tooltip/TooltipRenderedOnPageBody.js b/src/components/Tooltip/TooltipRenderedOnPageBody.js index 562842260f6c..11278650a913 100644 --- a/src/components/Tooltip/TooltipRenderedOnPageBody.js +++ b/src/components/Tooltip/TooltipRenderedOnPageBody.js @@ -64,8 +64,10 @@ class TooltipRenderedOnPageBody extends React.PureComponent { } componentDidMount() { - this.setState({ - tooltipTextWidth: this.textRef.offsetWidth, + this.textRef.measure((x, y, width) => { + this.setState({ + tooltipTextWidth: width, + }); }); } diff --git a/src/styles/getTooltipStyles.js b/src/styles/getTooltipStyles.js index e2f53956392b..baca706d652a 100644 --- a/src/styles/getTooltipStyles.js +++ b/src/styles/getTooltipStyles.js @@ -97,8 +97,7 @@ export default function getTooltipStyles( const tooltipVerticalPadding = spacing.pv1; const tooltipFontSize = variables.fontSizeSmall; - // We get wrapper width based on tooltip's inner text width so the wrapper - // is just big enough to fit text and prevent white space + // We get wrapper width based on tooltip's inner text width so the wrapper is just big enough to fit text and prevent white space const wrapperWidth = tooltipTextWidth && tooltipTextWidth < maxWidth // Add horizontal padding to the text width to get the wrapper width.