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 @@ -385,15 +385,6 @@ export type NativeProps = $ReadOnly<{|
|}>,
>,

onTextInput?: ?BubblingEventHandler<
$ReadOnly<{|
target: Int32,
text: string,
previousText: string,
range: $ReadOnly<{|start: Double, end: Double|}>,
|}>,
>,

/**
* Callback that is called when text input ends.
*/
Expand Down Expand Up @@ -662,12 +653,6 @@ export const __INTERNAL_VIEW_CONFIG: PartialViewConfig = {
captured: 'onSubmitEditingCapture',
},
},
topTextInput: {
phasedRegistrationNames: {
bubbled: 'onTextInput',
captured: 'onTextInputCapture',
},
},
},
directEventTypes: {
topScroll: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ const RCTTextInputViewConfig = {
},
},
directEventTypes: {
topTextInput: {
registrationName: 'onTextInput',
},
topScroll: {
registrationName: 'onScroll',
},
Expand Down Expand Up @@ -153,7 +150,6 @@ const RCTTextInputViewConfig = {
onSelectionChange: true,
onContentSizeChange: true,
onScroll: true,
onTextInput: true,
}),
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,15 +485,6 @@ export interface TextInputSubmitEditingEventData {
text: string;
}

/**
* @see TextInputProps.onTextInput
*/
export interface TextInputTextInputEventData {
text: string;
previousText: string;
range: {start: number; end: number};
}

/**
* @see https://reactnative.dev/docs/textinput#props
*/
Expand Down Expand Up @@ -787,16 +778,6 @@ export interface TextInputProps
| ((e: NativeSyntheticEvent<TextInputSubmitEditingEventData>) => void)
| undefined;

/**
* Callback that is called on new text input with the argument
* `{ nativeEvent: { text, previousText, range: { start, end } } }`.
*
* This prop requires multiline={true} to be set.
*/
onTextInput?:
| ((e: NativeSyntheticEvent<TextInputTextInputEventData>) => void)
| undefined;

/**
* Invoked on content scroll with
* `{ nativeEvent: { contentOffset: { x, y } } }`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, copy, nullable) RCTDirectEventBlock onSelectionChange;
@property (nonatomic, copy, nullable) RCTDirectEventBlock onChange;
@property (nonatomic, copy, nullable) RCTDirectEventBlock onChangeSync;
@property (nonatomic, copy, nullable) RCTDirectEventBlock onTextInput;
@property (nonatomic, copy, nullable) RCTDirectEventBlock onScroll;

@property (nonatomic, assign) NSInteger mostRecentEventCount;
Expand Down
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
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ @implementation RCTBaseTextInputViewManager {
RCT_EXPORT_VIEW_PROPERTY(onKeyPressSync, RCTDirectEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onChangeSync, RCTDirectEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onSelectionChange, RCTDirectEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onTextInput, RCTDirectEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onScroll, RCTDirectEventBlock)

RCT_EXPORT_VIEW_PROPERTY(mostRecentEventCount, NSInteger)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2281,14 +2281,6 @@ export type NativeProps = $ReadOnly<{|
contentSize: $ReadOnly<{| width: Double, height: Double |}>,
|}>,
>,
onTextInput?: ?BubblingEventHandler<
$ReadOnly<{|
target: Int32,
text: string,
previousText: string,
range: $ReadOnly<{| start: Double, end: Double |}>,
|}>,
>,
onEndEditing?: ?BubblingEventHandler<
$ReadOnly<{| target: Int32, text: string |}>,
>,
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 @@ -230,11 +230,6 @@ public Map<String, Object> getExportedCustomBubblingEventTypeConstants() {
MapBuilder.of(
"phasedRegistrationNames",
MapBuilder.of("bubbled", "onEndEditing", "captured", "onEndEditingCapture")))
.put(
"topTextInput",
MapBuilder.of(
"phasedRegistrationNames",
MapBuilder.of("bubbled", "onTextInput", "captured", "onTextInputCapture")))
.put(
"topFocus",
MapBuilder.of(
Expand Down Expand Up @@ -1120,17 +1115,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
27 changes: 9 additions & 18 deletions packages/react-native/ReactCommon/react/runtime/TimerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ void TimerManager::callReactNativeMicrotasks(jsi::Runtime& runtime) {
auto it = timers_.find(reactNativeMicrotaskID);
if (it != timers_.end()) {
it->second.invoke(runtime);
timers_.erase(it);

// Invoking a timer has the potential to delete it. Do not re-use the
// existing iterator to erase it from the map.
timers_.erase(reactNativeMicrotaskID);
}
}
}
Expand Down Expand Up @@ -101,9 +104,6 @@ void TimerManager::deleteReactNativeMicrotask(
timerHandle);
if (it != reactNativeMicrotasksQueue_.end()) {
reactNativeMicrotasksQueue_.erase(it);
}

if (timers_.find(timerHandle) != timers_.end()) {
timers_.erase(timerHandle);
}
}
Expand All @@ -114,9 +114,7 @@ void TimerManager::deleteTimer(jsi::Runtime& runtime, TimerHandle timerHandle) {
}

platformTimerRegistry_->deleteTimer(timerHandle);
if (timers_.find(timerHandle) != timers_.end()) {
timers_.erase(timerHandle);
}
timers_.erase(timerHandle);
}

void TimerManager::deleteRecurringTimer(
Expand All @@ -127,11 +125,7 @@ void TimerManager::deleteRecurringTimer(
}

platformTimerRegistry_->deleteTimer(timerHandle);

auto it = timers_.find(timerHandle);
if (it != timers_.end()) {
timers_.erase(it);
}
timers_.erase(timerHandle);
}

void TimerManager::callTimer(TimerHandle timerHandle) {
Expand All @@ -143,12 +137,9 @@ void TimerManager::callTimer(TimerHandle timerHandle) {
it->second.invoke(runtime);

if (!repeats) {
// Invoking a timer has the potential to delete it. Double check the
// timer still exists before accessing it again.
it = timers_.find(timerHandle);
if (it != timers_.end()) {
timers_.erase(it);
}
// Invoking a timer has the potential to delete it. Do not re-use the
// existing iterator to erase it from the map.
timers_.erase(timerHandle);
}
}
});
Expand Down