Slate: Cannot select past a void inline node in Firefox

Created on 10 Nov 2017  Â·  3Comments  Â·  Source: ianstormtaylor/slate

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

Bug

What's the current behavior?

  1. Open Emoji demo on Firefox (I use Windows, Firefox 56 and 57 Developer Edition)
  2. Try to select text and include Emoji in the selection
  3. Selection is collapsed to only one side of the emoji

(Could it be related to #1192?)

What's the expected behavior?

Should be able to select the text with the void inline node just like in Chrome

bug ♥ help

Most helpful comment

So... one way to fix the problem is to avoid switching contentEditable twice. If I remove contentEditable from the spacer element in void.js (line 72), it fixes the problem.

However, because there are two tests that check how void element is rendered, and changing this would make the tests fail. But I check the demos and they seem to work fine. How is this "spacer" being used and would removing contentEditable break anything? Since this is void node, I'm not expecting user to be able to edit the content (if I understand void node correctly)

All 3 comments

I investigated this and it might actually be a bug in Firefox's window.getSelection() itself.
Firefox has a problem dealing with contentEditable=true inside contentEditable=false inside contentEditable=true.

https://jsfiddle.net/varoot/gt0xm5mn/

So... one way to fix the problem is to avoid switching contentEditable twice. If I remove contentEditable from the spacer element in void.js (line 72), it fixes the problem.

However, because there are two tests that check how void element is rendered, and changing this would make the tests fail. But I check the demos and they seem to work fine. How is this "spacer" being used and would removing contentEditable break anything? Since this is void node, I'm not expecting user to be able to edit the content (if I understand void node correctly)

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ShardulNalegave picture ShardulNalegave  Â·  3Comments

yalu picture yalu  Â·  3Comments

ezakto picture ezakto  Â·  3Comments

bunterWolf picture bunterWolf  Â·  3Comments

gorillatron picture gorillatron  Â·  3Comments