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

Error thrown when typing on selected text #1509

Closed
fhelwanger opened this issue Nov 14, 2017 · 2 comments
Closed

Error thrown when typing on selected text #1509

fhelwanger opened this issue Nov 14, 2017 · 2 comments
Labels

Comments

@fhelwanger
Copy link

Do you want to request a feature or report a bug?

Bug.

What is the current behavior?

draft-js throws cannot read property 'update' of undefined when I type on selected text. To reproduce it, go to https://draftjs.org and type:

012
012
012

Then select the '1' of the second line. Now try to type '1'. Now type '2', it'll work. Now if you select the '2' that was just inserted and try to type '1' again, it'll not update.

Here's a gif demonstrating the bug:

screen

  • I can reproduce it on https://draftjs.org/ and in my projects too.
  • I can reproduce it with other strings too, like abc instead of 012

What is the expected behavior?

No errors thrown and the text should be updated correctly.

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.4
OS: Windows 10
Browser: Chrome 62, Firefox 56

I don't know if it worked on previous versions of draft-js. I'm a new user 😄

@juliankrispel
Copy link
Contributor

Very nice bug-report! Thanks a ton ❤️

@sontek
Copy link

sontek commented Dec 28, 2017

I just ran into this issue as well:

Uncaught TypeError: Cannot read property 'update' of undefined
    at editOnBeforeInput (editOnBeforeInput.js:101)
    at DraftEditor.react.js:146
    at HTMLUnknownElement.callCallback (react-dom.development.js:542)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:581)
    at Object.invokeGuardedCallback (react-dom.development.js:438)
    at Object.invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:452)
    at executeDispatch (react-dom.development.js:836)
    at executeDispatchesInOrder (react-dom.development.js:858)
    at executeDispatchesAndRelease (react-dom.development.js:956)
    at executeDispatchesAndReleaseTopLevel (react-dom.development.js:967)
    at Array.forEach (<anonymous>)
    at forEachAccumulated (react-dom.development.js:935)
    at processEventQueue (react-dom.development.js:1112)
    at runEventQueueInBatch (react-dom.development.js:3607)
    at handleTopLevel (react-dom.development.js:3616)
    at handleTopLevelImpl (react-dom.development.js:3347)
    at batchedUpdates (react-dom.development.js:11082)
    at batchedUpdates (react-dom.development.js:2330)
    at dispatchEvent (react-dom.development.js:3421)

which is happening because of this.update, I believe it should be editor.update here:

https://github.com/facebook/draft-js/blob/master/src/component/handlers/edit/editOnBeforeInput.js#L127-L128

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants