ianstormtaylor / slate

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

data-slate-spacer span is visible when void inline-elements are selected #5087

Open stefanli opened 2 years ago

stefanli commented 2 years ago

Description When a void inline-element is included in a selection, the data-slate-spacer span becomes visible, causing a slightly glitchy-looking selection. This is trivially re-produced in the official "Mentions" example here: https://www.slatejs.org/examples/mentions

Screenshots See the slightly darker colored selection color on the left side of the @character:

Screen Shot 2022-08-18 at 6 38 57 PM Screen Shot 2022-08-18 at 7 01 52 PM

Steps To reproduce the behavior:

  1. Go to https://www.slatejs.org/examples/mentions
  2. Select one of the @mention void elements.
  3. Observe the highlighted data-slate-space span element.

Expectation For the span not to be visible when selected like this:

Screen Shot 2022-08-18 at 6 39 40 PM

Environment

Context This can be fixed by using the following css:

[data-slate-spacer="true"] {
  visibility: hidden;
}

or alternatively:

[data-slate-spacer="true"] {
  user-select: none;
}

I haven't noticed any side-effects from testing these but I'm unsure if it is safe. Happy to submit a pull request if someone can chime in on the safety and which approach (if any) is preferred.

stefanli commented 2 years ago

Update: visibility: hidden is definitely not safe as it break keyboard navigation.

sensible-s commented 2 years ago

+1 would like to see this fix implemented.

Also, looks like it's an issue with Chrome:

Chrome

But not firefox:

Firefox