@@ -53,15 +53,16 @@ DateTimeField = React.createClass({
53
53
}
54
54
} ,
55
55
onChange : function ( event ) {
56
- if ( moment ( event . target . value , this . props . inputFormat , true ) . isValid ( ) ) {
56
+ var value = event . target == null ? event : event . target . value ;
57
+ if ( moment ( value , this . props . inputFormat , true ) . isValid ( ) ) {
57
58
this . setState ( {
58
- selectedDate : moment ( event . target . value , this . props . inputFormat , true ) ,
59
- viewDate : moment ( event . target . value , this . props . inputFormat , true ) . startOf ( "month" )
59
+ selectedDate : moment ( value , this . props . inputFormat , true ) ,
60
+ viewDate : moment ( value , this . props . inputFormat , true ) . startOf ( "month" )
60
61
} ) ;
61
62
}
62
63
63
64
return this . setState ( {
64
- inputValue : event . target . value
65
+ inputValue : value
65
66
} , function ( ) {
66
67
return this . props . onChange ( moment ( this . state . inputValue , this . props . inputFormat , true ) . format ( this . props . format ) ) ;
67
68
} ) ;
@@ -170,13 +171,9 @@ DateTimeField = React.createClass({
170
171
} ,
171
172
togglePeriod : function ( ) {
172
173
if ( this . state . selectedDate . hour ( ) > 12 ) {
173
- return this . setState ( {
174
- selectedDate : this . state . selectedDate . clone ( ) . subtract ( 12 , 'hours' )
175
- } ) ;
174
+ return this . onChange ( this . state . selectedDate . clone ( ) . subtract ( 12 , 'hours' ) . format ( this . props . inputFormat ) ) ;
176
175
} else {
177
- return this . setState ( {
178
- selectedDate : this . state . selectedDate . clone ( ) . add ( 12 , 'hours' )
179
- } ) ;
176
+ return this . onChange ( this . state . selectedDate . clone ( ) . add ( 12 , 'hours' ) . format ( this . props . inputFormat ) ) ;
180
177
}
181
178
} ,
182
179
togglePicker : function ( ) {
0 commit comments