From 5b98adf62979d9d60820ab88a75857000c7beb00 Mon Sep 17 00:00:00 2001 From: zhongwuzw Date: Wed, 27 Feb 2019 21:55:15 -0800 Subject: [PATCH] Fixed wrong placeholder size calculation in multiline text input mode (#23682) Summary: We have the wrong calculation of placeholder size currently, leads `contentSize` or some things inaccuracy. [iOS] [Fixed] - Fixed wrong placeholder size calculation in multiline text input mode Pull Request resolved: https://github.com/facebook/react-native/pull/23682 Differential Revision: D14255932 Pulled By: cpojer fbshipit-source-id: a1f40e90fc2c848579694965da8316fae9e5c4c5 --- Libraries/Text/TextInput/Multiline/RCTUITextView.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Libraries/Text/TextInput/Multiline/RCTUITextView.m b/Libraries/Text/TextInput/Multiline/RCTUITextView.m index e5679a13741ec7..5734672d13fa33 100644 --- a/Libraries/Text/TextInput/Multiline/RCTUITextView.m +++ b/Libraries/Text/TextInput/Multiline/RCTUITextView.m @@ -184,7 +184,8 @@ - (CGSize)placeholderSize { UIEdgeInsets textContainerInset = self.textContainerInset; NSString *placeholder = self.placeholder ?: @""; - CGSize placeholderSize = [placeholder sizeWithAttributes:@{NSFontAttributeName: self.font ?: defaultPlaceholderFont()}]; + CGSize maxPlaceholderSize = CGSizeMake(UIEdgeInsetsInsetRect(self.bounds, textContainerInset).size.width, CGFLOAT_MAX); + CGSize placeholderSize = [placeholder boundingRectWithSize:maxPlaceholderSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName: self.font ?: defaultPlaceholderFont()} context:nil].size; placeholderSize = CGSizeMake(RCTCeilPixelValue(placeholderSize.width), RCTCeilPixelValue(placeholderSize.height)); placeholderSize.width += textContainerInset.left + textContainerInset.right; placeholderSize.height += textContainerInset.top + textContainerInset.bottom;