Skip to content

Commit 8197e49

Browse files
committed
Pass empty to string to empty input instead of null
1 parent 09fc382 commit 8197e49

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/date_input.jsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ var DateInput = React.createClass({
2828

2929
getInitialState () {
3030
return {
31-
maybeDate: this.safeDateFormat(this.props)
31+
value: this.safeDateFormat(this.props)
3232
}
3333
},
3434

@@ -37,7 +37,7 @@ var DateInput = React.createClass({
3737
newProps.locale !== this.props.locale ||
3838
newProps.dateFormat !== this.props.dateFormat) {
3939
this.setState({
40-
maybeDate: this.safeDateFormat(newProps)
40+
value: this.safeDateFormat(newProps)
4141
})
4242
}
4343
},
@@ -60,20 +60,18 @@ var DateInput = React.createClass({
6060
this.props.onChangeDate(null)
6161
}
6262
}
63-
this.setState({
64-
maybeDate: value
65-
})
63+
this.setState({value})
6664
},
6765

6866
safeDateFormat (props) {
6967
return props.date && props.date.clone()
7068
.locale(props.locale || moment.locale())
71-
.format(props.dateFormat)
69+
.format(props.dateFormat) || ''
7270
},
7371

7472
handleBlur (event) {
7573
this.setState({
76-
maybeDate: this.safeDateFormat(this.props)
74+
value: this.safeDateFormat(this.props)
7775
})
7876
if (this.props.onBlur) {
7977
this.props.onBlur(event)
@@ -89,7 +87,7 @@ var DateInput = React.createClass({
8987
ref='input'
9088
type='text'
9189
{...this.props}
92-
value={this.state.maybeDate}
90+
value={this.state.value}
9391
onBlur={this.handleBlur}
9492
onChange={this.handleChange} />
9593
}

0 commit comments

Comments
 (0)