Slate: Mac's Text Replacement Doesn't Work

Created on 1 Nov 2019  Â·  2Comments  Â·  Source: ianstormtaylor/slate

Do you want to request a _feature_ or report a _bug_?

bug

What's the current behavior?

slateg

What's the expected behavior?

omw should get deleted

bug ♥ help

Most helpful comment

Maybe this comment will be helpful in the future. I tried this in my CR that has native browser manipulation on simple insertions (#3076) and it also breaks. I'm new to all the InputEvent stuff, but seems like the beforeinput event is the synthetic React one. It looks the same as an insertText event, so I don't know a way to know if it's replacing text without looking at the DOM change after allowing the native manipulation to proceed. Problem is, Chrome messes up and deletes a lot of the nested elements for the text Nodes, so it breaks the Slates' reconciliation (maybe this is a bug, if I have more time I'll look into this, seems like DraftJS has had problems with Chrome unexpectedly changing if allowing native events).

I tried what happens in Chrome outside of React using the native beforeInput event which should support InputEvents level two, but it also reports as inputType of insertText. This doesn't make sense as the spec makes it seem like insertReplacementText is more appropriate. Using insertReplacementTest is how Safari reports the event. I raised a Chrome bug for for this in the meantime (1021460).

This may be fixable in Safari if we can use the native beforeinput event.

Another link for reference.

All 2 comments

Maybe this comment will be helpful in the future. I tried this in my CR that has native browser manipulation on simple insertions (#3076) and it also breaks. I'm new to all the InputEvent stuff, but seems like the beforeinput event is the synthetic React one. It looks the same as an insertText event, so I don't know a way to know if it's replacing text without looking at the DOM change after allowing the native manipulation to proceed. Problem is, Chrome messes up and deletes a lot of the nested elements for the text Nodes, so it breaks the Slates' reconciliation (maybe this is a bug, if I have more time I'll look into this, seems like DraftJS has had problems with Chrome unexpectedly changing if allowing native events).

I tried what happens in Chrome outside of React using the native beforeInput event which should support InputEvents level two, but it also reports as inputType of insertText. This doesn't make sense as the spec makes it seem like insertReplacementText is more appropriate. Using insertReplacementTest is how Safari reports the event. I raised a Chrome bug for for this in the meantime (1021460).

This may be fixable in Safari if we can use the native beforeinput event.

Another link for reference.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gorillatron picture gorillatron  Â·  3Comments

ianstormtaylor picture ianstormtaylor  Â·  3Comments

chriserickson picture chriserickson  Â·  3Comments

bunterWolf picture bunterWolf  Â·  3Comments

ianstormtaylor picture ianstormtaylor  Â·  3Comments