Draft-js: Disable default drag and drop functionality in editor

Created on 18 Jul 2017  路  1Comment  路  Source: facebook/draft-js

Do you want to request a feature or report a bug?
Feature. Related closed issues: https://github.com/facebook/draft-js/issues/291 and https://github.com/facebook/draft-js/issues/494

What is the current behavior?
I have a custom react-dnd enabled content block that I can drag other UI components into. This all works fine, but the problem is draft-js' default onDrop handler which triggers a JS error when trying to read text.length:

react-dom.min.js:14 Uncaught TypeError: Cannot read property 'length' of null
    at insertTextIntoContentState (Draft.js:10378)
    at Object.replaceText (Draft.js:831)
    at Object.insertText (Draft.js:836)
    at insertTextAtSelection (Draft.js:7142)
    at onDrop (Draft.js:7128)
    at Draft.js:6294

My editor:

<Editor
  blockRendererFn={this.renderBlock}
  editorState={this.state.editorState}
  handleDrop={() => true}
  onChange={this.handleChange}
  plugins={draftJSPlugins}
/>

What is the expected behavior?
Some method to disable the default onDrop behavior in the editor

Which versions of Draft.js, and which browser / OS are affected by this issue? Did this work in previous versions of Draft.js?
draft-js: 0.10.1

Most helpful comment

NOTE: if you're using the Editor from draft-js-plugins-editor you'll have to explicitly return 'handled' for this to work!

>All comments

NOTE: if you're using the Editor from draft-js-plugins-editor you'll have to explicitly return 'handled' for this to work!

Was this page helpful?
0 / 5 - 0 ratings