Skip to content

Commit

Permalink
Do not send extra onChangeText even wnen instantianting multiline Tex…
Browse files Browse the repository at this point in the history
…tView (#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: 62fa281308b9d2e0a807d024f08d8a214bd99b5e
  • Loading branch information
dmytrorykun authored and facebook-github-bot committed Apr 18, 2023
1 parent 6dcdd2e commit a804c0f
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -256,21 +256,21 @@ - (BOOL)textView:(__unused UITextView *)textView shouldChangeTextInRange:(NSRang

- (void)textViewDidChange:(__unused UITextView *)textView
{
if (_ignoreNextTextInputCall && [_lastStringStateWasUpdatedWith isEqual:_backedTextInputView.attributedText]) {
if (_ignoreNextTextInputCall) {
_ignoreNextTextInputCall = NO;
return;
}
_lastStringStateWasUpdatedWith = _backedTextInputView.attributedText;
_textDidChangeIsComing = NO;
[_backedTextInputView.textInputDelegate textInputDidChange];
}

- (void)textViewDidChangeSelection:(__unused UITextView *)textView
{
if (![_lastStringStateWasUpdatedWith isEqual:_backedTextInputView.attributedText]) {
if (_lastStringStateWasUpdatedWith && ![_lastStringStateWasUpdatedWith isEqual:_backedTextInputView.attributedText]) {
[self textViewDidChange:_backedTextInputView];
_ignoreNextTextInputCall = YES;
}
_lastStringStateWasUpdatedWith = _backedTextInputView.attributedText;
[self textViewProbablyDidChangeSelection];
}

Expand Down

0 comments on commit a804c0f

Please sign in to comment.