Skip to content

Commit b402552

Browse files
dmytrorykunfacebook-github-bot
authored andcommitted
Do not send extra onChangeText even wnen instantianting multiline TextView (#36930)
Summary: Pull Request resolved: #36930 This diff fixes #36494 Now this code matches its [Fabric counterpart](7b48899). There is also one extra check that `_lastStringStateWasUpdatedWith != nil`. With that in place we don't send extra `onChangeText` event when `attributedText` is assigned for the first time on TextView construction. Changelog: [IOS][Fixed] - Do not send extra onChangeText even wnen instantianting multiline TextView Reviewed By: sammy-SC Differential Revision: D45049135 fbshipit-source-id: 3351b9b62fca5e8722c8da08f2c081b857164458
1 parent 07df82b commit b402552

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/react-native/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,21 +256,21 @@ - (BOOL)textView:(__unused UITextView *)textView shouldChangeTextInRange:(NSRang
256256

257257
- (void)textViewDidChange:(__unused UITextView *)textView
258258
{
259-
if (_ignoreNextTextInputCall && [_lastStringStateWasUpdatedWith isEqual:_backedTextInputView.attributedText]) {
259+
if (_ignoreNextTextInputCall) {
260260
_ignoreNextTextInputCall = NO;
261261
return;
262262
}
263-
_lastStringStateWasUpdatedWith = _backedTextInputView.attributedText;
264263
_textDidChangeIsComing = NO;
265264
[_backedTextInputView.textInputDelegate textInputDidChange];
266265
}
267266

268267
- (void)textViewDidChangeSelection:(__unused UITextView *)textView
269268
{
270-
if (![_lastStringStateWasUpdatedWith isEqual:_backedTextInputView.attributedText]) {
269+
if (_lastStringStateWasUpdatedWith && ![_lastStringStateWasUpdatedWith isEqual:_backedTextInputView.attributedText]) {
271270
[self textViewDidChange:_backedTextInputView];
272271
_ignoreNextTextInputCall = YES;
273272
}
273+
_lastStringStateWasUpdatedWith = _backedTextInputView.attributedText;
274274
[self textViewProbablyDidChangeSelection];
275275
}
276276

0 commit comments

Comments
 (0)