Skip to content

Commit 02b453f

Browse files
committed
Merge pull request quri#41 from wu-h/master
FIX: inputValue did not update after clicking add/subtract Minute/Hour
2 parents f98307e + e2ab2b4 commit 02b453f

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/DateTimeField.jsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,20 @@ DateTimeField = React.createClass({
117117
return this.setState({
118118
selectedDate: this.state.selectedDate.clone().add(1, "minutes")
119119
}, function() {
120-
return this.props.onChange(this.state.selectedDate.format(this.props.format));
120+
this.props.onChange(this.state.selectedDate.format(this.props.format));
121+
return this.setState({
122+
inputValue: this.state.selectedDate.format(this.props.inputFormat)
123+
});
121124
});
122125
},
123126
addHour: function() {
124127
return this.setState({
125128
selectedDate: this.state.selectedDate.clone().add(1, "hours")
126129
}, function() {
127-
return this.props.onChange(this.state.selectedDate.format(this.props.format));
130+
this.props.onChange(this.state.selectedDate.format(this.props.format));
131+
return this.setState({
132+
inputValue: this.state.selectedDate.format(this.props.inputFormat)
133+
});
128134
});
129135
},
130136
addMonth: function() {
@@ -146,14 +152,20 @@ DateTimeField = React.createClass({
146152
return this.setState({
147153
selectedDate: this.state.selectedDate.clone().subtract(1, "minutes")
148154
}, function() {
149-
return this.props.onChange(this.state.selectedDate.format(this.props.format));
155+
this.props.onChange(this.state.selectedDate.format(this.props.format));
156+
return this.setState({
157+
inputValue: this.state.selectedDate.format(this.props.inputFormat)
158+
});
150159
});
151160
},
152161
subtractHour: function() {
153162
return this.setState({
154163
selectedDate: this.state.selectedDate.clone().subtract(1, "hours")
155164
}, function() {
156-
return this.props.onChange(this.state.selectedDate.format(this.props.format));
165+
this.props.onChange(this.state.selectedDate.format(this.props.format));
166+
return this.setState({
167+
inputValue: this.state.selectedDate.format(this.props.inputFormat)
168+
});
157169
});
158170
},
159171
subtractMonth: function() {

0 commit comments

Comments
 (0)