ProseMirror / prosemirror

The ProseMirror WYSIWYM editor
http://prosemirror.net/
MIT License
7.59k stars 335 forks source link

Letter automatically selected when typing it for the first time #1378

Closed auromota closed 1 year ago

auromota commented 1 year ago

Hi there!

When you load the input and type something for the first time (and only the first time, I believe), it will automatically create a selection for the first letter you just typed in. When you enter the second letter, it will override the first letter, since there was a selection in the first letter. After this, the bug doesn't seem to happen again, unless you refresh your browser. In the end, we have this weird behavior, where if you type "Swim", you'll end up getting the word "Wim".

I created this minimum project to reproduce the bug. https://codepen.io/aurofmota/full/jOeJKMR

In the following video, I typed "Asd" and got "Sd" in the end. https://github.com/ProseMirror/prosemirror/assets/7283335/826e5195-1d08-4d29-9783-87684137a172

I tried in a few different devices and it won't happen on every one of them, but it's consistently happening on the ones I could reproduce. iOS seems to be working just fine.

List of devices where the bug happens:

  1. Samsung Galaxy S9 / Chrome (only if using Samsung keyboard. Other keyboards worked just fine)
  2. Samsung Galaxy S23 / Chrome (I only tried the Samsung keyboard, and it was broken there as well)
  3. Google Pixel 4 / Chrome (using Gboard)
  4. Google Pixel 7 / Chrome (not sure which keyboard I used)

Thanks, Auro.

marijnh commented 1 year ago

Use doc: { content: "paragraph+" } instead of "paragraph*". This is caused by the original text being inserted outside of a textblock, which apparently causes the android browser to do weird things with the selection as the wrapping block node is added.