Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
9 changes: 0 additions & 9 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -7662,15 +7662,6 @@ public class com/facebook/react/views/textinput/ReactTextChangedEvent : com/face
public fun getEventName ()Ljava/lang/String;
}

public class com/facebook/react/views/textinput/ReactTextInputEvent : com/facebook/react/uimanager/events/Event {
public static final field EVENT_NAME Ljava/lang/String;
public fun <init> (IILjava/lang/String;Ljava/lang/String;II)V
public fun <init> (ILjava/lang/String;Ljava/lang/String;II)V
public fun canCoalesce ()Z
protected fun getEventData ()Lcom/facebook/react/bridge/WritableMap;
public fun getEventName ()Ljava/lang/String;
}

public final class com/facebook/react/views/textinput/ReactTextInputLocalData {
public fun <init> (Landroid/widget/EditText;)V
public fun apply (Landroid/widget/EditText;)V
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import com.facebook.react.uimanager.events.Event;

/** Event emitted by EditText native view when key pressed */
class ReactTextInputKeyPressEvent extends Event<ReactTextInputEvent> {
/* package */ class ReactTextInputKeyPressEvent extends Event<ReactTextInputKeyPressEvent> {

public static final String EVENT_NAME = "topKeyPress";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1120,17 +1120,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