Skip to content

Commit

Permalink
Implemented onChange event handler
Browse files Browse the repository at this point in the history
  • Loading branch information
n4kz committed May 10, 2017
1 parent 8225d19 commit 6f31504
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/components/field/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export default class TextField extends PureComponent {
this.onBlur = this.onBlur.bind(this);
this.onFocus = this.onFocus.bind(this);
this.onPress = this.focus.bind(this);
this.onChange = this.onChange.bind(this);
this.onChangeText = this.onChangeText.bind(this);
this.onContentSizeChange = this.onContentSizeChange.bind(this);

Expand Down Expand Up @@ -170,6 +171,19 @@ export default class TextField extends PureComponent {
this.setState({ focused: false });
}

onChange(event) {
let { onChange, multiline } = this.props;

if ('function' === typeof onChange) {
onChange(event);
}

/* XXX: onContentSizeChange is not called on RN 0.44 */
if (multiline && 'android' === Platform.OS) {
this.onContentSizeChange(event);
}
}

onChangeText(text) {
let { onChangeText } = this.props;

Expand Down Expand Up @@ -291,8 +305,8 @@ export default class TextField extends PureComponent {
{...props}

editable={!disabled && editable}
onChange={this.onChange}
onChangeText={this.onChangeText}
onChange={this.onContentSizeChange}
onContentSizeChange={this.onContentSizeChange}
onFocus={this.onFocus}
onBlur={this.onBlur}
Expand Down

0 comments on commit 6f31504

Please sign in to comment.