File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed
test/specs/elements/Input Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -116,7 +116,7 @@ class Input extends Component {
116116 /** An Icon Input field can show that it is currently loading data */
117117 loading : PropTypes . bool ,
118118
119- /** Called with (e, props ) on change. */
119+ /** Called with (e, data ) on change. */
120120 onChange : PropTypes . func ,
121121
122122 /** An Input can vary in size */
@@ -137,7 +137,12 @@ class Input extends Component {
137137
138138 handleChange = ( e ) => {
139139 const { onChange } = this . props
140- if ( onChange ) onChange ( e , this . props )
140+ if ( onChange ) {
141+ onChange ( e , {
142+ ...this . props ,
143+ value : _ . get ( e , 'target.value' ) ,
144+ } )
145+ }
141146 }
142147
143148 render ( ) {
Original file line number Diff line number Diff line change @@ -73,17 +73,17 @@ describe('Input', () => {
7373 } )
7474
7575 describe ( 'onChange' , ( ) => {
76- it ( 'is called with (event, props ) on change' , ( ) => {
76+ it ( 'is called with (e, data ) on change' , ( ) => {
7777 const spy = sandbox . spy ( )
78- const event = { fake : 'event' }
78+ const e = { target : { value : 'name' } }
7979 const props = { 'data-foo' : 'bar' , onChange : spy }
8080
8181 const wrapper = shallow ( < Input { ...props } /> )
8282
83- wrapper . find ( 'input' ) . simulate ( 'change' , event )
83+ wrapper . find ( 'input' ) . simulate ( 'change' , e )
8484
8585 spy . should . have . been . calledOnce ( )
86- spy . should . have . been . calledWithMatch ( event , props )
86+ spy . should . have . been . calledWithMatch ( e , { ... props , value : e . target . value } )
8787 } )
8888 } )
8989} )
You can’t perform that action at this time.
0 commit comments