From bb6bfe0e4ff1eb37dbb301016c25c9b4937dfb80 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Sat, 13 Feb 2016 21:30:11 +0000 Subject: [PATCH] Prefer selection to dragging in IE for editable elements Fixes #13 --- src/HTML5Backend.js | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/HTML5Backend.js b/src/HTML5Backend.js index f7add2c..b92bdc3 100644 --- a/src/HTML5Backend.js +++ b/src/HTML5Backend.js @@ -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(); } }