Skip to content

Commit d7fa81f

Browse files
sherginfacebook-github-bot
authored andcommitted
Fixed double onChange event triggering from <TextInput> on iOS
Summary: The problem was recently introduced in the last refactoring of the Text module. There are two problem actually: (1) Compare this current code with stable version. In the stable version the event is only triggered here: https://github.com/facebook/react-native/blob/0.52-stable/Libraries/Text/RCTTextField.m#L132-L140 In the new version the event is triggered in two places (which is obviously wrong). (2) Executing `[_eventDispatcher sendTextEventWithType:RCTTextEventTypeChange:...]` and _onChange() actually do the same thing. Historically, the single-line <TextInput> used the first approach and multi-line used second one. When we unify the logic, mixed both of them, which was apparenly wrong. So, we have to remove another call of `[_eventDispatcher sendTextEventWithType:RCTTextEventTypeChange:...]`. The the future we have to completly remove usage of `_eventDispatcher` from this component. Depends on D6854770. Reviewed By: fkgozali Differential Revision: D6869678 fbshipit-source-id: 6705ee8dda2681ae184ef6716238cc8b62efeff1
1 parent 7492860 commit d7fa81f

File tree

1 file changed

+0
-12
lines changed

1 file changed

+0
-12
lines changed

Libraries/Text/TextInput/RCTBaseTextInputView.m

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -286,12 +286,6 @@ - (BOOL)textInputShouldChangeTextInRange:(NSRange)range replacementText:(NSStrin
286286
});
287287
}
288288

289-
[_eventDispatcher sendTextEventWithType:RCTTextEventTypeChange
290-
reactTag:self.reactTag
291-
text:backedTextInputView.attributedText.string
292-
key:nil
293-
eventCount:_nativeEventCount];
294-
295289
return YES;
296290
}
297291

@@ -324,12 +318,6 @@ - (void)textInputDidChange
324318
@"eventCount": @(_nativeEventCount),
325319
});
326320
}
327-
328-
[_eventDispatcher sendTextEventWithType:RCTTextEventTypeChange
329-
reactTag:self.reactTag
330-
text:backedTextInputView.attributedText.string
331-
key:nil
332-
eventCount:_nativeEventCount];
333321
}
334322

335323
- (void)textInputDidChangeSelection

0 commit comments

Comments
 (0)