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

Commit e7ae2e7

Browse files
Jack Armstrongfacebook-github-bot
authored andcommitted
Fix draftjs type error for event
Summary: Fixes an issue introduced by D13137413 where we weren't safely getting the right document for an event target, if the event target is null. Fixes by using the safer `getCorretDocumentFromNode`, which uses the defualt `document` if the argument is null. Reviewed By: claudiopro Differential Revision: D18618225 fbshipit-source-id: bc381a5000318c5065fdf856387dd038b7e04003
1 parent dceddf5 commit e7ae2e7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/component/handlers/drag/DraftEditorDragHandler.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const EditorState = require('EditorState');
2020
const ReactDOM = require('ReactDOM');
2121

2222
const findAncestorOffsetKey = require('findAncestorOffsetKey');
23+
const getCorrectDocumentFromNode = require('getCorrectDocumentFromNode');
2324
const getTextContentFromFiles = require('getTextContentFromFiles');
2425
const getUpdatedSelectionState = require('getUpdatedSelectionState');
2526
const getWindowForNode = require('getWindowForNode');
@@ -36,13 +37,12 @@ function getSelectionForEvent(
3637
let node: ?Node = null;
3738
let offset: ?number = null;
3839

40+
const eventTargetDocument = getCorrectDocumentFromNode(event.currentTarget);
3941
/* $FlowFixMe(>=0.68.0 site=www,mobile) This comment suppresses an error
4042
* found when Flow v0.68 was deployed. To see the error delete this comment
4143
* and run Flow. */
42-
const {ownerDocument} = event.currentTarget;
43-
44-
if (typeof ownerDocument.caretRangeFromPoint === 'function') {
45-
const dropRange = ownerDocument.caretRangeFromPoint(event.x, event.y);
44+
if (typeof eventTargetDocument.caretRangeFromPoint === 'function') {
45+
const dropRange = eventTargetDocument.caretRangeFromPoint(event.x, event.y);
4646
node = dropRange.startContainer;
4747
offset = dropRange.startOffset;
4848
} else if (event.rangeParent) {

0 commit comments

Comments
 (0)