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 @@ -416,6 +416,8 @@ export default class InputRange extends React.Component {
416416 return ;
417417 }
418418
419+ event . preventDefault ( ) ;
420+
419421 const key = getKeyByPosition ( this , position ) ;
420422
421423 this . updatePosition ( key , position ) ;
Original file line number Diff line number Diff line change @@ -279,9 +279,23 @@ describe('InputRange', () => {
279279 event = {
280280 clientX : 100 ,
281281 clientY : 200 ,
282+ preventDefault : jasmine . createSpy ( 'preventDefault' ) ,
282283 } ;
283284 } ) ;
284285
286+ it ( 'should call event.preventDefault if not disabled' , ( ) => {
287+ inputRange . handleTrackMouseDown ( event , track , position ) ;
288+
289+ expect ( event . preventDefault ) . toHaveBeenCalledWith ( ) ;
290+ } ) ;
291+
292+ it ( 'should not call event.preventDefault if disabled' , ( ) => {
293+ inputRange = renderComponent ( < InputRange disabled = { true } defaultValue = { 10 } onChange = { onChange } /> ) ;
294+ inputRange . handleTrackMouseDown ( event , track , position ) ;
295+
296+ expect ( event . preventDefault ) . not . toHaveBeenCalledWith ( ) ;
297+ } ) ;
298+
285299 it ( 'should not set a new position if disabled' , ( ) => {
286300 inputRange = renderComponent ( < InputRange disabled = { true } defaultValue = { 10 } onChange = { onChange } /> ) ;
287301 spyOn ( inputRange , 'updatePosition' ) ;
You can’t perform that action at this time.
0 commit comments