Skip to content

Commit 5da40cb

Browse files
javacheTitozzz
authored andcommitted
Stop emitting deprecated onTextInput events (#44479)
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
1 parent 10e9669 commit 5da40cb

File tree

5 files changed

+1
-98
lines changed

5 files changed

+1
-98
lines changed

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

-13
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

-9
Original file line numberDiff line numberDiff line change
@@ -7362,15 +7362,6 @@ public class com/facebook/react/views/textinput/ReactTextChangedEvent : com/face
73627362
public fun getEventName ()Ljava/lang/String;
73637363
}
73647364

7365-
public class com/facebook/react/views/textinput/ReactTextInputEvent : com/facebook/react/uimanager/events/Event {
7366-
public static final field EVENT_NAME Ljava/lang/String;
7367-
public fun <init> (IILjava/lang/String;Ljava/lang/String;II)V
7368-
public fun <init> (ILjava/lang/String;Ljava/lang/String;II)V
7369-
public fun canCoalesce ()Z
7370-
protected fun getEventData ()Lcom/facebook/react/bridge/WritableMap;
7371-
public fun getEventName ()Ljava/lang/String;
7372-
}
7373-
73747365
public final class com/facebook/react/views/textinput/ReactTextInputLocalData {
73757366
public fun <init> (Landroid/widget/EditText;)V
73767367
public fun apply (Landroid/widget/EditText;)V

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

-70
This file was deleted.

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

+1-1
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

-5
Original file line numberDiff line numberDiff line change
@@ -1122,17 +1122,12 @@ public void onTextChanged(CharSequence s, int start, int before, int count) {
11221122
}
11231123

11241124
// The event that contains the event counter and updates it must be sent first.
1125-
// TODO: t7936714 merge these events
11261125
mEventDispatcher.dispatchEvent(
11271126
new ReactTextChangedEvent(
11281127
mSurfaceId,
11291128
mEditText.getId(),
11301129
s.toString(),
11311130
mEditText.incrementAndGetEventCounter()));
1132-
1133-
mEventDispatcher.dispatchEvent(
1134-
new ReactTextInputEvent(
1135-
mSurfaceId, mEditText.getId(), newText, oldText, start, start + before));
11361131
}
11371132

11381133
@Override

0 commit comments

Comments
 (0)