File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -422,6 +422,8 @@ export default class InputRange extends React.Component {
422422 return ;
423423 }
424424
425+ event . preventDefault ( ) ;
426+
425427 const key = getKeyByPosition ( this , position ) ;
426428
427429 this . updatePosition ( key , position ) ;
Original file line number Diff line number Diff line change @@ -357,9 +357,23 @@ describe('InputRange', () => {
357357 event = {
358358 clientX : 100 ,
359359 clientY : 200 ,
360+ preventDefault : jasmine . createSpy ( 'preventDefault' ) ,
360361 } ;
361362 } ) ;
362363
364+ it ( 'should call event.preventDefault if not disabled' , ( ) => {
365+ inputRange . handleTrackMouseDown ( event , track , position ) ;
366+
367+ expect ( event . preventDefault ) . toHaveBeenCalledWith ( ) ;
368+ } ) ;
369+
370+ it ( 'should not call event.preventDefault if disabled' , ( ) => {
371+ inputRange = renderComponent ( < InputRange disabled = { true } defaultValue = { 10 } onChange = { onChange } /> ) ;
372+ inputRange . handleTrackMouseDown ( event , track , position ) ;
373+
374+ expect ( event . preventDefault ) . not . toHaveBeenCalledWith ( ) ;
375+ } ) ;
376+
363377 it ( 'should not set a new position if disabled' , ( ) => {
364378 inputRange = renderComponent ( < InputRange disabled = { true } defaultValue = { 10 } onChange = { onChange } /> ) ;
365379 spyOn ( inputRange , 'updatePosition' ) ;
You can’t perform that action at this time.
0 commit comments