From 0df10002394a989a4ca7adcb7e33bc428ac4bcf7 Mon Sep 17 00:00:00 2001 From: Lawrence Win Date: Tue, 21 Jan 2025 21:26:59 -0800 Subject: [PATCH] fix(textinput): Account for float dimensions when showing scroller (#2341) * Account for float dimensions when showing scroller * Use fabs() --------- Co-authored-by: Saad Najmi --- .../Text/TextInput/Multiline/RCTMultilineTextInputView.mm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/react-native/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputView.mm b/packages/react-native/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputView.mm index 7bc2c53c52c857..9be90e85d16870 100644 --- a/packages/react-native/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputView.mm +++ b/packages/react-native/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputView.mm @@ -134,7 +134,9 @@ - (BOOL)shouldShowVerticalScrollbar CGSize textViewSize = [_backedTextInputView intrinsicContentSize]; NSClipView *clipView = (NSClipView *)_scrollView.contentView; if (textViewSize.height > clipView.bounds.size.height) { - return YES; + // Sometimes dimensions returned are in floating point numbers. + // If the floats are close enough, then don't show the scrollbar even if there is a fraction of overflow with the text. + return fabs(textViewSize.height - clipView.bounds.size.height) >= 1; }; return NO;