ianstormtaylor / slate

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

Changes.deleteBackwardAtRange fails when first node is a void node #1199

Closed jimmynguyc closed 7 years ago

jimmynguyc commented 7 years ago

This problem is reproducible on http://slatejs.org/#/emojis.

Screencast: http://recordit.co/RUJliirLNR

Platform: macOS Sierra 10.12.6 Browser: Chrome 61.0.3163.100(Official Build)

Failure happens when a line begins with a void node + some texts, go to end of line, cmd + backspace.

It fails at https://github.com/ianstormtaylor/slate/blob/master/packages/slate/src/changes/at-range.js#L428 when node = document.getNextText(parent.key) returns undefined on #L423.

Also, correct me if I'm wrong, but if I'm deleting backwards shouldn't the final focus be the one before the void node (if any)? So maybe getPreviousSubling(parent.key) instead?

jimmynguyc commented 7 years ago

Thanks @doodlewind @ianstormtaylor :)