ianstormtaylor / slate

A completely customizable framework for building rich text editors. (Currently in beta.)
http://slatejs.org
MIT License
29.91k stars 3.25k forks source link

Slate crash when changing to readOnly after insert inlineElement via click and not preventDefault #1602

Closed X-Tender closed 4 years ago

X-Tender commented 6 years ago

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

Bug

What's the current behavior?

Slate crash with error

Unable to find a DOM node for "13". This is often because of forgetting to add props.attributes to a custom component.

When inserting inline element via click Event and didn't call preserveDefaulton the click Event, and changing the readOnly mode to true after that. When I click into the edit area and then toggle the readOnly mode the error did not occur.

Example (Emoji example from website): https://codepen.io/XTender/pen/WMrEwJ?editors=1010

Sure the "Bug" can be omitted by using e.preventDefault() but I thought if this is the correct behavior if it doesn't.

What's the expected behavior?

Should not crash :)

ianstormtaylor commented 4 years ago

I believe that this may be fixed by https://github.com/ianstormtaylor/slate/pull/3093, which has changed a lot of the logic in Slate and slate-react especially. I'm going to close this out, but as always, feel free to open a new issue if it persists for you. Thanks for understanding.