Skip to content

Commit 8ed0de5

Browse files
dmytrorykunSaadnajmi
authored andcommitted
Do not send extra onChangeText even wnen instantianting multiline TextView (facebook#36930)
Summary: Pull Request resolved: facebook#36930 This diff fixes facebook#36494 Now this code matches its [Fabric counterpart](facebook@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: 62fa281308b9d2e0a807d024f08d8a214bd99b5e
1 parent 789dbc7 commit 8ed0de5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,11 +368,10 @@ - (BOOL)textView:(__unused UITextView *)textView shouldChangeTextInRange:(NSRang
368368

369369
- (void)textViewDidChange:(__unused UITextView *)textView
370370
{
371-
if (_ignoreNextTextInputCall && [_lastStringStateWasUpdatedWith isEqual:_backedTextInputView.attributedText]) {
371+
if (_ignoreNextTextInputCall) {
372372
_ignoreNextTextInputCall = NO;
373373
return;
374374
}
375-
_lastStringStateWasUpdatedWith = _backedTextInputView.attributedText;
376375
_textDidChangeIsComing = NO;
377376
[_backedTextInputView.textInputDelegate textInputDidChange];
378377
}
@@ -381,10 +380,11 @@ - (void)textViewDidChange:(__unused UITextView *)textView
381380

382381
- (void)textViewDidChangeSelection:(__unused UITextView *)textView
383382
{
384-
if (![_lastStringStateWasUpdatedWith isEqual:_backedTextInputView.attributedText]) {
383+
if (_lastStringStateWasUpdatedWith && ![_lastStringStateWasUpdatedWith isEqual:_backedTextInputView.attributedText]) {
385384
[self textViewDidChange:_backedTextInputView];
386385
_ignoreNextTextInputCall = YES;
387386
}
387+
_lastStringStateWasUpdatedWith = _backedTextInputView.attributedText;
388388
[self textViewProbablyDidChangeSelection];
389389
}
390390

0 commit comments

Comments
 (0)