Skip to content

Commit

Permalink
Fixes some drag-n-drop problems (facebookarchive#1599)
Browse files Browse the repository at this point in the history
Summary:
**Summary**
Fixes issue facebookarchive#1383. Fixes problem which is: onDrop breaks onSelect/onChange events.
Fixes issue facebookarchive#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 facebookarchive#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 facebookarchive#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: facebookarchive#1599

Differential Revision: D10236073

fbshipit-source-id: 3b7b816630f3b5b15931cb53782a1d5b9e9d5121
  • Loading branch information
ukrbublik authored and jdecked committed Oct 9, 2019
1 parent 5b83561 commit 1a4b9b6
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions src/component/handlers/drag/DraftEditorDragHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand Down

0 comments on commit 1a4b9b6

Please sign in to comment.