From 1a4b9b64dba00845a93da711792e7527f4a9ba2f Mon Sep 17 00:00:00 2001 From: Denis Oblogin Date: Wed, 10 Oct 2018 14:37:25 -0700 Subject: [PATCH] Fixes some drag-n-drop problems (#1599) Summary: **Summary** Fixes issue #1383. Fixes problem which is: onDrop breaks onSelect/onChange events. Fixes issue #1454 (partial). Fixes problem which is: after first internal drop dragged text will not be moved to target position, but copied. The solution is to set `editor._internalDrag` to false not during onDragOver events, but after end of drag-n-drop. **Test Plan** Attached reproducable videos (on Chrome for Linux) Issue #1383 before and after: ![1383-before](https://user-images.githubusercontent.com/3238637/46585340-68ec4100-ca78-11e8-9c2f-c98e7cb381ff.gif) ![1383-after](https://user-images.githubusercontent.com/3238637/46585344-6c7fc800-ca78-11e8-9c2e-fdac5594d1d0.gif) Issue #1454 before and after: ![1454-before](https://user-images.githubusercontent.com/3238637/46585364-9e912a00-ca78-11e8-9c17-5dfcec5a2e16.gif) ![1454-after](https://user-images.githubusercontent.com/3238637/46585361-9a650c80-ca78-11e8-8b7f-dac6c6af4b23.gif) Pull Request resolved: https://github.com/facebook/draft-js/pull/1599 Differential Revision: D10236073 fbshipit-source-id: 3b7b816630f3b5b15931cb53782a1d5b9e9d5121 --- .../handlers/drag/DraftEditorDragHandler.js | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/component/handlers/drag/DraftEditorDragHandler.js b/src/component/handlers/drag/DraftEditorDragHandler.js index 84857177d6..fead709485 100644 --- a/src/component/handlers/drag/DraftEditorDragHandler.js +++ b/src/component/handlers/drag/DraftEditorDragHandler.js @@ -121,11 +121,7 @@ const DraftEditorDragHandler = { editor.update(moveText(editorState, dropSelection)); } else { editor.update( - insertTextAtSelection( - editorState, - dropSelection, - (data.getText(): any), - ), + insertTextAtSelection(editorState, dropSelection, (data.getText(): any)), ); } endDrag(editor); @@ -138,14 +134,6 @@ const DraftEditorDragHandler = { onDragOver: function onDragOver(editor: DraftEditor, e: Object): void { e.preventDefault(); }, - - /** - * Edge disallows drag event by default (A No Symbol (⃠) will be shown on the dragged image by default). - * Without preventing the default dragOver handler a drop event can not be triggered. - */ - onDragOver: function onDragOver(editor: DraftEditor, e: Object): void { - e.preventDefault(); - }, }; function endDrag(editor) {