Slate: onDrop breaks onSelect event

Created on 30 Jun 2017  路  4Comments  路  Source: ianstormtaylor/slate

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

Bug

What's the current behavior?

onDrop events result in an editor with a broken selection. More specifically, the onSelect handler of the main contentEditable div never gets called after the drop event has fired.

As you can see in this gif below, the onSelect event gets called each time I move the cursor around (using the arrow keys). But once the onDrop event has fired, onSelect doesn't fire when moving the cursor around (also using the keys):

slate-gif

Here's the fiddle I used to record the demo above.

Additional info:

  • It doesn't matter what we do in the onDrop handler. Inserting nodes (of any kind), or simply giving the editor focus, results in the same behavior.
  • If we blur the editor in onDrop, and let the user re-focus (by clicking), everything works again.
  • I remember having a similar problem when using Draft a few months back.
bug

Most helpful comment

I was trying to fix this today, but was unable to find a solution. I did however narrow down the problem quite a lot, and I've updated the issue accordingly. I'll probably have another stab at this in the upcoming days/weeks, but any ideas or tips would be very welcome!

All 4 comments

I was trying to fix this today, but was unable to find a solution. I did however narrow down the problem quite a lot, and I've updated the issue accordingly. I'll probably have another stab at this in the upcoming days/weeks, but any ideas or tips would be very welcome!

@tobiasandersen is this still an issue in the newest version of Slate?

I'm afraid it is: https://jsfiddle.net/c3nscb3c/1/ (updated in the original post as well)

I'm pretty sure this isn't an issue with Slate, but rather with React. I just created an issue on their tracker: https://github.com/facebook/react/issues/11379.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bunterWolf picture bunterWolf  路  3Comments

ianstormtaylor picture ianstormtaylor  路  3Comments

markolofsen picture markolofsen  路  3Comments

ianstormtaylor picture ianstormtaylor  路  3Comments

bengotow picture bengotow  路  3Comments