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

Bug: Cannot find DOMPoint after applying formatting keyboard shortcuts (onDOMBeforeInput->event.inputType) - also in stock examples #3586

Open beorn opened 4 years ago

beorn commented 4 years ago

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

Bug

What's the current behavior?

  1. Go to https://www.slatejs.org/examples/hovering-toolbar
  2. Replace all content with just 'abc'
  3. Select the 'c'
  4. Press Cmd-B or Cmd-I
  5. The app crashes

Debugging locally it seems to Editor.node(editor, point.path) in toDOMPoint finds the wrong node when looking for the domPoint of domFocus.

What's the expected behavior?

It should bold or italicize the c — the same behavior as pressing the formatting buttons in the hovering toolbar.

Screen Shot 2020-04-05 at 17 23 17 Screen Shot 2020-04-05 at 17 35 09
beorn commented 4 years ago

It seems that calling event.preventDefault() if handling the event seems to fix the error at least. I'm not sure if this is the right approach?