Skip to content

Commit

Permalink
update comment and change offsetWidth to measure function
Browse files Browse the repository at this point in the history
  • Loading branch information
LucioChavezFuentes committed May 3, 2022
1 parent 6ade224 commit e098176
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/components/Tooltip/TooltipRenderedOnPageBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
});
}

Expand Down
3 changes: 1 addition & 2 deletions src/styles/getTooltipStyles.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit e098176

Please sign in to comment.