Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Commit

Permalink
Only set value if debounce when onBlur/onSubmit.
Browse files Browse the repository at this point in the history
  • Loading branch information
T4rk1n committed Dec 3, 2018
1 parent 4c1f6b2 commit 967dd66
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/components/Input.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,27 @@ export default class Input extends Component {
if (setProps) {
const castValue =
type === 'number' ? Number(value) : value;
setProps({
const payload = {
n_blur: this.props.n_blur + 1,
n_blur_timestamp: new Date(),
value: castValue,
});
};
if (debounce) {
payload.value = castValue;
}
setProps(payload);
}
}}
onKeyPress={e => {
if (setProps && e.key === 'Enter') {
const castValue =
type === 'number' ? Number(value) : value;
setProps({
const payload = {
n_submit: this.props.n_submit + 1,
n_submit_timestamp: new Date(),
value: castValue,
});
};
if (debounce) {
payload.value =
type === 'number' ? Number(value) : value;
}
setProps(payload);
}
}}
value={value}
Expand Down

0 comments on commit 967dd66

Please sign in to comment.