From e076b954aad1d03213c3408f743bc9594b959b66 Mon Sep 17 00:00:00 2001 From: LucioChavezFuentes Date: Tue, 3 May 2022 01:36:24 +0200 Subject: [PATCH] move wrapper width condition to getTooltipStyles --- .../Tooltip/TooltipRenderedOnPageBody.js | 12 ++---------- src/styles/getTooltipStyles.js | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/components/Tooltip/TooltipRenderedOnPageBody.js b/src/components/Tooltip/TooltipRenderedOnPageBody.js index 75d5fbeef3d3..66ba3a57cd44 100644 --- a/src/components/Tooltip/TooltipRenderedOnPageBody.js +++ b/src/components/Tooltip/TooltipRenderedOnPageBody.js @@ -4,7 +4,6 @@ import {Animated, View} from 'react-native'; import ReactDOM from 'react-dom'; import getTooltipStyles from '../../styles/getTooltipStyles'; import Text from '../Text'; -import spacing from '../../styles/utilities/spacing'; const propTypes = { /** Window width */ @@ -83,14 +82,6 @@ class TooltipRenderedOnPageBody extends React.PureComponent { } render() { - // 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 = this.state.tooltipTextWidth && this.state.tooltipTextWidth < this.props.maxWidth - - // Add horizontal padding to the text width to get the wrapper width. - // TooltipTextWidth ignores the fractions (OffsetWidth) so add 1px to fit the text properly. - ? this.state.tooltipTextWidth + (spacing.ph2.paddingHorizontal * 2) + 1 - : this.props.maxWidth; const { animationStyle, tooltipWrapperStyle, @@ -106,9 +97,10 @@ class TooltipRenderedOnPageBody extends React.PureComponent { this.props.wrapperHeight, this.state.tooltipWidth, this.state.tooltipHeight, + this.state.tooltipTextWidth, this.props.shiftHorizontal, this.props.shiftVertical, - wrapperWidth, + this.props.maxWidth, ); return ReactDOM.createPortal(