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

Commit

Permalink
Remove findDOMNode in DraftEditorDragHandler
Browse files Browse the repository at this point in the history
Summary:
As in my previous change, editor.editorContainer is always an element and doesn't need findDOMNode.

https://github.com/facebook/draft-js/blob/822d2fbd3597c3fe20cc2508d6a12d9a6f856999/src/component/base/DraftEditor.react.js#L370

This isn't exactly the same because the previous code got the parent node:

https://github.com/facebook/draft-js/blob/822d2fbd3597c3fe20cc2508d6a12d9a6f856999/src/component/base/DraftEditor.react.js#L366

However for this purpose they're the same. There are no listeners on the inner one and the event bubbles. We already have a ref to the inner one so might as well use it.

Now I think that this has since been fixed in React so we might  not need this workaround at all anymore.

Reviewed By: gaearon

Differential Revision: D19540873

fbshipit-source-id: 89f91105b97ae6b0eeb5b4d615642a79eef6ab92
  • Loading branch information
sebmarkbage authored and facebook-github-bot committed Jan 23, 2020
1 parent 9d587d9 commit c1a55ce
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/component/handlers/drag/DraftEditorDragHandler.js
Expand Up @@ -17,7 +17,6 @@ import type SelectionState from 'SelectionState';
const DataTransfer = require('DataTransfer');
const DraftModifier = require('DraftModifier');
const EditorState = require('EditorState');
const ReactDOM = require('ReactDOM');

const findAncestorOffsetKey = require('findAncestorOffsetKey');
const getCorrectDocumentFromNode = require('getCorrectDocumentFromNode');
Expand Down Expand Up @@ -142,7 +141,7 @@ function endDrag(editor) {
// Prior to React v16.5.0 onDrop breaks onSelect event:
// https://github.com/facebook/react/issues/11379.
// Dispatching a mouseup event on DOM node will make it go back to normal.
const editorNode = ReactDOM.findDOMNode(editor);
const editorNode = editor.editorContainer;
if (editorNode) {
const mouseUpEvent = new MouseEvent('mouseup', {
view: getWindowForNode(editorNode),
Expand Down

0 comments on commit c1a55ce

Please sign in to comment.