Skip to content

Commit c9ae68a

Browse files
Revert "Fix Max Length 0 issue on iOS"
This reverts commit 99dbaa7.
1 parent 99dbaa7 commit c9ae68a

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,8 @@ - (NSString *)textInputShouldChangeText:(NSString *)text inRange:(NSRange)range
450450
}
451451
}
452452

453-
if (props.maxLength.has_value()) {
454-
NSInteger allowedLength = props.maxLength.value() - _backedTextInputView.attributedText.string.length + range.length;
453+
if (props.maxLength) {
454+
NSInteger allowedLength = props.maxLength - _backedTextInputView.attributedText.string.length + range.length;
455455

456456
if (allowedLength > 0 && text.length > allowedLength) {
457457
// make sure unicode characters that are longer than 16 bits (such as emojis) are not cut off

packages/react-native/ReactCommon/react/renderer/components/textinput/BaseTextInputProps.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include <react/renderer/core/PropsParserContext.h>
1515
#include <react/renderer/graphics/Color.h>
1616
#include <string>
17-
#include <optional>
1817

1918
namespace facebook::react {
2019

@@ -61,7 +60,7 @@ class BaseTextInputProps : public ViewProps, public BaseTextProps {
6160
// TODO: Rename to `tintColor` and make universal.
6261
SharedColor underlineColorAndroid{};
6362

64-
std::optional<int> maxLength{};
63+
int maxLength{};
6564

6665
/*
6766
* "Private" (only used by TextInput.js) props

packages/react-native/ReactCommon/react/renderer/components/textinput/platform/android/react/renderer/components/androidtextinput/AndroidTextInputProps.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ folly::dynamic AndroidTextInputProps::getDynamic() const {
304304
props["maxFontSizeMultiplier"] = maxFontSizeMultiplier;
305305
props["keyboardType"] = keyboardType;
306306
props["returnKeyType"] = returnKeyType;
307-
props["maxLength"] = maxLength.has_value() ? maxLength.value() : folly::dynamic();
307+
props["maxLength"] = maxLength;
308308
props["multiline"] = multiline;
309309
props["placeholder"] = placeholder;
310310
props["placeholderTextColor"] = toAndroidRepr(placeholderTextColor);
@@ -456,7 +456,7 @@ folly::dynamic AndroidTextInputProps::getDiffProps(
456456
}
457457

458458
if (maxLength != oldProps->maxLength) {
459-
result["maxLength"] = maxLength.has_value() ? maxLength.value() : folly::dynamic();
459+
result["maxLength"] = maxLength;
460460
}
461461

462462
if (text != oldProps->text) {

0 commit comments

Comments
 (0)