Skip to content

Commit

Permalink
Fix onKeyUp, close ant-design/ant-design#4717
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 committed Jan 25, 2017
1 parent 74ab28e commit 998b124
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
8 changes: 8 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# History
----

## 3.0.2

- Fix `onKeyUp`.

## 3.0.1

- Fix invalid input like '11x'.

## 3.0.0

- Trigger onChange when user input
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rc-input-number",
"version": "3.0.1",
"version": "3.0.2",
"description": "input-number ui component for react(web & react-native)",
"keywords": [
"react",
Expand Down
16 changes: 14 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const InputNumber = React.createClass({
focusOnUpDown: PropTypes.bool,
onChange: PropTypes.func,
onKeyDown: PropTypes.func,
onKeyUp: PropTypes.func,
prefixCls: PropTypes.string,
disabled: PropTypes.bool,
onFocus: PropTypes.func,
Expand Down Expand Up @@ -55,7 +56,18 @@ const InputNumber = React.createClass({
} else if (e.keyCode === 40) {
this.down(e);
}
this.props.onKeyDown(e, ...args);
const { onKeyDown } = this.props;
if (onKeyDown) {
onKeyDown(e, ...args);
}
},

onKeyUp(e, ...args) {
this.stop();
const { onKeyUp } = this.props;
if (onKeyUp) {
onKeyUp(e, ...args);
}
},

getValueFromEvent(e) {
Expand Down Expand Up @@ -157,7 +169,7 @@ const InputNumber = React.createClass({
onFocus={this.onFocus}
onBlur={this.onBlur}
onKeyDown={this.onKeyDown}
onKeyUp={this.stop}
onKeyUp={this.onKeyUp}
autoFocus={props.autoFocus}
readOnly={props.readOnly}
disabled={props.disabled}
Expand Down

0 comments on commit 998b124

Please sign in to comment.