Skip to content
This repository has been archived by the owner on Jun 18, 2018. It is now read-only.

Commit

Permalink
Prefer selection to dragging in IE for editable elements
Browse files Browse the repository at this point in the history
Fixes #13
  • Loading branch information
gaearon committed Feb 13, 2016
1 parent f3ced55 commit bb6bfe0
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions src/HTML5Backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,11 +494,27 @@ export default class HTML5Backend {
}

handleSelectStart(e) {
// Prevent selection on IE
// and instead ask it to consider dragging.
if (typeof e.target.dragDrop === 'function') {
e.preventDefault();
e.target.dragDrop();
const { target } = e;

// Only IE requires us to explicitly say
// we want drag drop operation to start
if (typeof target.dragDrop !== 'function') {
return;
}

// Inputs and textareas should be selectable
if (
target.tagName === 'INPUT' ||
target.tagName === 'SELECT' ||
target.tagName === 'TEXTAREA' ||
target.isContentEditable
) {
return;
}

// For other targets, ask IE
// to enable drag and drop
e.preventDefault();
target.dragDrop();
}
}

0 comments on commit bb6bfe0

Please sign in to comment.