mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-30 22:12:42 +08:00
Don't send same text changes from text input
Differential Revision: D2663576 fb-gh-sync-id: 259040eda54982c10374f9f1ee89f67a459937d0
This commit is contained in:
committed by
facebook-github-bot-7
parent
5b796cec34
commit
fc511f0730
@@ -320,9 +320,17 @@ public class ReactTextInputManager extends
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
// Rearranging the text (i.e. changing between singleline and multiline attributes) can
|
||||
// also trigger onTextChanged, call the event in JS only when the text actually changed
|
||||
if (count > 0 || before > 0) {
|
||||
Assertions.assertNotNull(mPreviousText);
|
||||
if (count == 0 && before == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Assertions.assertNotNull(mPreviousText);
|
||||
String newText = s.toString().substring(start, start + count);
|
||||
String oldText = mPreviousText.substring(start, start + before);
|
||||
// Don't send same text changes
|
||||
if (count == before && newText.equals(oldText)) {
|
||||
return;
|
||||
}
|
||||
int contentWidth = mEditText.getWidth();
|
||||
int contentHeight = mEditText.getHeight();
|
||||
|
||||
@@ -349,12 +357,11 @@ public class ReactTextInputManager extends
|
||||
new ReactTextInputEvent(
|
||||
mEditText.getId(),
|
||||
SystemClock.uptimeMillis(),
|
||||
count > 0 ? s.toString().substring(start, start + count) : "",
|
||||
before > 0 ? mPreviousText.substring(start, start + before) : "",
|
||||
newText,
|
||||
oldText,
|
||||
start,
|
||||
count > 0 ? start + count - 1 : start + before));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
Reference in New Issue
Block a user