bustle/mobiledoc-kit

Text suggestions and autocorrect don't work on iOS

JBYoshi opened this issue · 4 comments

When typing into the editor on iOS, the text suggestion bar doesn't behave normally:

  • The first letter typed acts as if it is its own word (for example, typing "H" suggests "h I", "h is", "h you").
  • Further letters typed do not update the suggestions.
  • Typos are not suggested for autocorrect, even when they would be in other contexts.

Based on my research into this issue, it seems to be related to calling preventDefault() on the key events. Using onbeforeinput instead does not have this problem.

Video: https://user-images.githubusercontent.com/12983479/145438053-7c590790-52fe-42ff-a994-225f2005035c.mov

Tested on https://bustle.github.io/mobiledoc-kit/demo/debug.html using Safari on iOS 15.1. Originally reported as TryGhost/Ghost#13097.

This is a rough duplicate of #621 - there's a lot more details in there about the cause if anyone wants to dig in and work on a PR.

@JBYoshi This seems to be linked to inserting emoji as well, do you have a repo of you experiments you did so far?

It's been a while since I looked at this, but I pushed a copy of my workspace with some work-in-progress stuff. JBYoshi@66a36a4 is the original state of my workspace last I worked on it. I've merged in the latest changes to https://github.com/JBYoshi/mobiledoc-kit/tree/input-events.

For the emoji setup, it turns out that there is a separate piece of the code that's not behaving properly; using input events instead just bypasses the broken code. I created a separate PR to fix the original bug with emojis: #764