draft-js icon indicating copy to clipboard operation
draft-js copied to clipboard

Draft breaks when pressing enter on atomic block

Open leniartek opened this issue 7 years ago • 4 comments

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

What is the current behavior? When the Image is not 100% wide in the editor and you focus cursor after it and press enter you get.

invariant.js:44 Uncaught Invariant Violation: Unknown DraftEntity key.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. You can use this jsfiddle to get started: https://jsfiddle.net/stopachka/m6z0xn4r/.

In Media example remove the width styles like showed below. https://github.com/facebook/draft-js/compare/master...leniartek:patch-1 Than place the cursor after image and press enter. image

What is the expected behavior?

Enter to create a empty new line after image.

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

all draft versions all browsers

leniartek avatar May 04 '17 13:05 leniartek

The example is a bit misleading. It probably shouldn't try to use img directly as the atomic block, but should instead use a wrapper div and apply the width to that. Then the img can be an arbitrary width, but the div width should remain 100%.

Beyond that, it's currently a limitation that the cursor can't really be adjacent to an atomic block in this way. It would be great to have a really solid solution for this, but in the meantime the example should be changed.

hellendag avatar Jun 15 '17 22:06 hellendag

Any recommendation how handle this?

epozsh avatar Aug 11 '17 14:08 epozsh

Any updates on this or any example how to handle this?

DivyanshGothwal avatar Sep 06 '20 20:09 DivyanshGothwal

Hi, is anyone working on it? i am new to open source, how do i get started?

SachinCoder1 avatar Feb 20 '22 18:02 SachinCoder1