Skip to content
This repository was archived by the owner on Feb 6, 2023. It is now read-only.

Commit 800d6b5

Browse files
laysentfacebook-github-bot
authored andcommitted
Fix drop issue (#1725)
Summary: **Summary** I have created a demo to illustrate this issue, feel free to look at [here](https://github.com/laysent/draft-js-drag-and-drop-issue) If you look at `src/component/base/DraftEditor.react.js`, there is a problem with `_dragCount`: When you drag a file into editor and drop it, `onDragEnter` will be triggered to increase `this._dragCount`. However, `onDragLeave` will not be triggered when dropping, thus `this._dragCount` will not be decreased back to 0. Thus, after dragging and dropping, when user drags another file and NOT drop it, both `onDragEnter` and `onDragLeave` will be triggered. This time, `this._dragCount` will be increased then decreased. However, since it's initial value after dropping is not 0, it will not be decreased back to 0 after `dragLeave`, thus it will not trigger `this.exitCurrentMode()` in `onDragLeave`. Editor remains in "drag" mode. To resolve this issue, simply set `_dragCount` back to 0 when dropping the file. **Test Plan** I don't think one is necessary for this issue. But would be happy to provide one if required. Pull Request resolved: #1725 Differential Revision: D10234644 fbshipit-source-id: 6b8ffeef21899d80f623db3554dd688038ed92ac
1 parent d87e093 commit 800d6b5

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/component/handlers/drag/DraftEditorDragHandler.js

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ const DraftEditorDragHandler = {
8484
);
8585

8686
e.preventDefault();
87+
editor._dragCount = 0;
8788
editor.exitCurrentMode();
8889

8990
if (dropSelection == null) {

0 commit comments

Comments
 (0)