@@ -53,15 +53,16 @@ DateTimeField = React.createClass({
5353 }
5454 } ,
5555 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 ( ) ) {
5758 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" )
6061 } ) ;
6162 }
6263
6364 return this . setState ( {
64- inputValue : event . target . value
65+ inputValue : value
6566 } , function ( ) {
6667 return this . props . onChange ( moment ( this . state . inputValue , this . props . inputFormat , true ) . format ( this . props . format ) ) ;
6768 } ) ;
@@ -170,13 +171,9 @@ DateTimeField = React.createClass({
170171 } ,
171172 togglePeriod : function ( ) {
172173 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 ) ) ;
176175 } 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 ) ) ;
180177 }
181178 } ,
182179 togglePicker : function ( ) {
0 commit comments