Skip to content

Commit

Permalink
Merge pull request davidchin#22 from esseb/text-selection
Browse files Browse the repository at this point in the history
Prevent text selection during drag
  • Loading branch information
davidchin committed Apr 10, 2016
2 parents 75f90f8 + ce7b7e1 commit 1a31253
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/InputRange/InputRange.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,8 @@ export default class InputRange extends React.Component {
return;
}

event.preventDefault();

const key = getKeyByPosition(this, position);

this.updatePosition(key, position);
Expand Down
14 changes: 14 additions & 0 deletions test/InputRange.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,23 @@ describe('InputRange', () => {
event = {
clientX: 100,
clientY: 200,
preventDefault: jasmine.createSpy('preventDefault'),
};
});

it('should call event.preventDefault if not disabled', () => {
inputRange.handleTrackMouseDown(event, track, position);

expect(event.preventDefault).toHaveBeenCalledWith();
});

it('should not call event.preventDefault if disabled', () => {
inputRange = renderComponent(<InputRange disabled={true} defaultValue={10} onChange={onChange}/>);
inputRange.handleTrackMouseDown(event, track, position);

expect(event.preventDefault).not.toHaveBeenCalledWith();
});

it('should not set a new position if disabled', () => {
inputRange = renderComponent(<InputRange disabled={true} defaultValue={10} onChange={onChange}/>);
spyOn(inputRange, 'updatePosition');
Expand Down

0 comments on commit 1a31253

Please sign in to comment.