From c73ceff914e7b81b02b8ffd47e727c725969368f Mon Sep 17 00:00:00 2001 From: Quentin Adam Date: Tue, 13 Oct 2015 06:17:07 -0700 Subject: [PATCH] Corrected computation of RCText element height with padding MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Corrected computation of RCText element height with padding (padding was counted twice). See also issue #2466. Closes https://github.com/facebook/react-native/pull/2838 Reviewed By: @​svcscm Differential Revision: D2535924 Pulled By: @nicklockwood fb-gh-sync-id: b9527803c0a5a6eed1db7e37c98b628750ab2045 --- Libraries/Text/RCTShadowText.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Libraries/Text/RCTShadowText.m b/Libraries/Text/RCTShadowText.m index 357c3784c..33e8c8485 100644 --- a/Libraries/Text/RCTShadowText.m +++ b/Libraries/Text/RCTShadowText.m @@ -86,7 +86,10 @@ static css_dim_t RCTMeasure(void *context, float width) parentProperties = [super processUpdatedProperties:applierBlocks parentProperties:parentProperties]; - NSTextStorage *textStorage = [self buildTextStorageForWidth:self.frame.size.width]; + UIEdgeInsets padding = self.paddingAsInsets; + CGFloat width = self.frame.size.width - (padding.left + padding.right); + + NSTextStorage *textStorage = [self buildTextStorageForWidth:width]; [applierBlocks addObject:^(RCTSparseArray *viewRegistry) { RCTText *view = viewRegistry[self.reactTag]; view.textStorage = textStorage; @@ -105,9 +108,6 @@ static css_dim_t RCTMeasure(void *context, float width) - (NSTextStorage *)buildTextStorageForWidth:(CGFloat)width { - UIEdgeInsets padding = self.paddingAsInsets; - width -= (padding.left + padding.right); - if (_cachedTextStorage && width == _cachedTextStorageWidth) { return _cachedTextStorage; }