Skip to content

Commit

Permalink
[iOS] Fixed onChange prop of textinput not be called in some cases
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongwuzw committed Feb 28, 2019
1 parent fc91bcc commit f032e7a
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions Libraries/Text/TextInput/RCTBaseTextInputView.m
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,16 @@ - (BOOL)textInputShouldChangeTextInRange:(NSRange)range replacementText:(NSStrin
notifyDelegate:YES];

[self textInputDidChange];

_nativeEventCount++;

if (_onChange) {
_onChange(@{
@"text": _predictedText,
@"target": self.reactTag,
@"eventCount": @(_nativeEventCount),
});
}
}

return NO;
Expand Down Expand Up @@ -423,6 +433,16 @@ - (BOOL)textInputShouldChangeTextInRange:(NSRange)range replacementText:(NSStrin
@"eventCount": @(_nativeEventCount),
});
}

_nativeEventCount++;

if (_onChange) {
_onChange(@{
@"text": _predictedText,
@"target": self.reactTag,
@"eventCount": @(_nativeEventCount),
});
}

return YES;
}
Expand All @@ -446,16 +466,6 @@ - (void)textInputDidChange
[self textInputDidChangeSelection];
_predictedText = backedTextInputView.attributedText.string;
}

_nativeEventCount++;

if (_onChange) {
_onChange(@{
@"text": self.attributedText.string,
@"target": self.reactTag,
@"eventCount": @(_nativeEventCount),
});
}
}

- (void)textInputDidChangeSelection
Expand Down

0 comments on commit f032e7a

Please sign in to comment.