Draft-js: Error if there is no property "text" in the DataTransfer object while dropping

Created on 27 Jun 2016  路  12Comments  路  Source: facebook/draft-js

I am dragging and dropping image-, video and slideshow-objects into the draft-js editor. To give the drop handler the information he needs to insert that object i am serializing a data object into the DataTransfer object. That's why i do not need the text-property of the DataTransfer object. If there is no text-property set on the DataTransfer object, draft-js raises an error:

Uncaught TypeError: Cannot read property 'length' of null
  insertTextIntoContentState
  replaceText
  insertText
  insertTextAtSelection
  onDrop
  ...

Is there a way to avoid this error if i do not want to insert any text and handle the drop action by myself? Or is this a bug?

bug

Most helpful comment

@delijah this quick fix solves the problem for a while.
https://github.com/facebook/draft-js/pull/864/commits/62ff707f73bb92716292df60e2d34cdb1ab656b0 as @spicyj recommended.

All 12 comments

I think it would be reasonable to only call this.update() here if data.getText() returns non-null:

https://github.com/facebook/draft-js/blob/9ce1bab81cd006666a1a47b724e7c06f97c4ea1f/src/component/handlers/drag/DraftEditorDragHandler.js#L123

I have also encountered this while using Draft+react-dnd

image

Any progress on this?

@delijah this quick fix solves the problem for a while.
https://github.com/facebook/draft-js/pull/864/commits/62ff707f73bb92716292df60e2d34cdb1ab656b0 as @spicyj recommended.

Closing because of inactivity.

does this need a PR? still running into this...

Still running into this as well with react-dnd-enabled blocks

NOTE: if you're using the <Editor /> component from draft-js-plugins-editor you'll have to explicitly return 'handled' instead of true for this to work

I am still seeing this error - is there a timeline for that commit being merged?

Since people still get this error and would like to see it fixed, i reopen this issue hereby.

I am still seeing this error as well - I would love to see the fix implemented. Need a PR?

This should be fixed by #2117. Please reopen if you believe this is not addressed @delijah

Was this page helpful?
0 / 5 - 0 ratings