Don't apply empty attributed string for TextInput (#25143)

Summary:
Issue reported by Titozzz , `TextInput` would shrink when we have attributes like `lineHeight`.
Demonstration can see GIF like below:
https://giphy.com/gifs/KGNs1qIMHF3DIk1EPK

I think the reason is we apply an empty attributed string to `UITextField`, now if the length is 0, we just nil the `attributedText` instead.

## Changelog

[iOS] [Fixed] - Don't apply empty attributed string for TextInput
Pull Request resolved: https://github.com/facebook/react-native/pull/25143

Differential Revision: D15661751

Pulled By: sammy-SC

fbshipit-source-id: 9770484a1b68a6409e63ea25ac9a6fd0d3589b14
This commit is contained in:
zhongwuzw
2019-06-06 09:17:16 -07:00
committed by Facebook Github Bot
parent 63bc4b4aac
commit 9b61896f40
2 changed files with 7 additions and 2 deletions
@@ -174,7 +174,12 @@
baseTextInputView.reactPaddingInsets = paddingInsets;
if (isAttributedTextChanged) {
baseTextInputView.attributedText = attributedText;
// Don't set `attributedText` if length equal to zero, otherwise it would shrink when attributes contain like `lineHeight`.
if (attributedText.length != 0) {
baseTextInputView.attributedText = attributedText;
} else {
baseTextInputView.attributedText = nil;
}
}
}];
}