Skip to content

Commit

Permalink
Stop emitting deprecated onTextInput events (#44479)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #44479

TextInputs' onTextInput callback was removed way back in React Native 0.62 with 3f7e0a2 , but remnants of the implementation exists.

We first have to remove the event emitting in native code, and can land the full removal separately in D57092733, once there's no older client references remaining to this event.

Changelog: [General][Removed] Remove deprecated onTextInput callback

Reviewed By: cipolleschi

Differential Revision: D57092734

fbshipit-source-id: 5b0beee3d55b70717216fe8ceaf52444540f5adc
  • Loading branch information
javache authored and cipolleschi committed Oct 7, 2024
1 parent 9049306 commit e6ad652
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -493,26 +493,13 @@ - (NSString *)textInputShouldChangeText:(NSString *)text inRange:(NSRange)range
}
}

NSString *previousText = [backedTextInputView.attributedText.string copy] ?: @"";

if (range.location + range.length > backedTextInputView.attributedText.string.length) {
_predictedText = backedTextInputView.attributedText.string;
} else if (text != nil) {
_predictedText = [backedTextInputView.attributedText.string stringByReplacingCharactersInRange:range
withString:text];
}

if (_onTextInput) {
_onTextInput(@{
// We copy the string here because if it's a mutable string it may get released before we stop using it on a
// different thread, causing a crash.
@"text" : [text copy],
@"previousText" : previousText,
@"range" : @{@"start" : @(range.location), @"end" : @(range.location + range.length)},
@"eventCount" : @(_nativeEventCount),
});
}

return text; // Accepting the change.
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -1062,17 +1062,12 @@ public void onTextChanged(CharSequence s, int start, int before, int count) {
}

// The event that contains the event counter and updates it must be sent first.
// TODO: t7936714 merge these events
mEventDispatcher.dispatchEvent(
new ReactTextChangedEvent(
mSurfaceId,
mEditText.getId(),
s.toString(),
mEditText.incrementAndGetEventCounter()));

mEventDispatcher.dispatchEvent(
new ReactTextInputEvent(
mSurfaceId, mEditText.getId(), newText, oldText, start, start + before));
}

@Override
Expand Down

0 comments on commit e6ad652

Please sign in to comment.