Skip to content

Commit 3e2309e

Browse files
javachekosmydel
authored andcommitted
Stop emitting deprecated onTextInput events (facebook#44479)
Summary: Pull Request resolved: facebook#44479 TextInputs' onTextInput callback was removed way back in React Native 0.62 with facebook@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
1 parent 6e61cde commit 3e2309e

5 files changed

Lines changed: 1 addition & 98 deletions

File tree

packages/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.mm

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -493,26 +493,13 @@ - (NSString *)textInputShouldChangeText:(NSString *)text inRange:(NSRange)range
493493
}
494494
}
495495

496-
NSString *previousText = [backedTextInputView.attributedText.string copy] ?: @"";
497-
498496
if (range.location + range.length > backedTextInputView.attributedText.string.length) {
499497
_predictedText = backedTextInputView.attributedText.string;
500498
} else if (text != nil) {
501499
_predictedText = [backedTextInputView.attributedText.string stringByReplacingCharactersInRange:range
502500
withString:text];
503501
}
504502

505-
if (_onTextInput) {
506-
_onTextInput(@{
507-
// We copy the string here because if it's a mutable string it may get released before we stop using it on a
508-
// different thread, causing a crash.
509-
@"text" : [text copy],
510-
@"previousText" : previousText,
511-
@"range" : @{@"start" : @(range.location), @"end" : @(range.location + range.length)},
512-
@"eventCount" : @(_nativeEventCount),
513-
});
514-
}
515-
516503
return text; // Accepting the change.
517504
}
518505

packages/react-native/ReactAndroid/api/ReactAndroid.api

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7698,15 +7698,6 @@ public class com/facebook/react/views/textinput/ReactTextChangedEvent : com/face
76987698
public fun getEventName ()Ljava/lang/String;
76997699
}
77007700

7701-
public class com/facebook/react/views/textinput/ReactTextInputEvent : com/facebook/react/uimanager/events/Event {
7702-
public static final field EVENT_NAME Ljava/lang/String;
7703-
public fun <init> (IILjava/lang/String;Ljava/lang/String;II)V
7704-
public fun <init> (ILjava/lang/String;Ljava/lang/String;II)V
7705-
public fun canCoalesce ()Z
7706-
protected fun getEventData ()Lcom/facebook/react/bridge/WritableMap;
7707-
public fun getEventName ()Ljava/lang/String;
7708-
}
7709-
77107701
public final class com/facebook/react/views/textinput/ReactTextInputLocalData {
77117702
public fun <init> (Landroid/widget/EditText;)V
77127703
public fun apply (Landroid/widget/EditText;)V

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputEvent.java

Lines changed: 0 additions & 70 deletions
This file was deleted.

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputKeyPressEvent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import com.facebook.react.uimanager.events.Event;
1515

1616
/** Event emitted by EditText native view when key pressed */
17-
class ReactTextInputKeyPressEvent extends Event<ReactTextInputEvent> {
17+
/* package */ class ReactTextInputKeyPressEvent extends Event<ReactTextInputKeyPressEvent> {
1818

1919
public static final String EVENT_NAME = "topKeyPress";
2020

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,17 +1120,12 @@ public void onTextChanged(CharSequence s, int start, int before, int count) {
11201120
}
11211121

11221122
// The event that contains the event counter and updates it must be sent first.
1123-
// TODO: t7936714 merge these events
11241123
mEventDispatcher.dispatchEvent(
11251124
new ReactTextChangedEvent(
11261125
mSurfaceId,
11271126
mEditText.getId(),
11281127
s.toString(),
11291128
mEditText.incrementAndGetEventCounter()));
1130-
1131-
mEventDispatcher.dispatchEvent(
1132-
new ReactTextInputEvent(
1133-
mSurfaceId, mEditText.getId(), newText, oldText, start, start + before));
11341129
}
11351130

11361131
@Override

0 commit comments

Comments
 (0)