question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Predictive text input on iOS

See original GitHub issue

Slate seem to work really well on iOS apart from predictive text input (the suggested words above the keyboard). When tapping on one of the suggestions, the text is simply appended instead of replacing the current word.

The event triggered by tapping on the suggestions is first an event of type textInput with the word in data followed by an event of type input. This is then followed by another textInput with a single space character in data and finally another input event.

So far I’ve been unable to determine from the information in the events what data should be removed before inserting the suggestion. Unfortunately you can’t either have a simple rule like deleting backwards to the first space as you could backspace over the previous space, which doesn’t change the suggestions offered by the keyboard.

A workaround is to bail out early in onBeforeInput: https://github.com/julienp/slate/commit/85886812e4789ce5dcf529bb5834b4339d76786e

Of course this skips the ‘native’ check in core.js onBeforeInput and forces a rerender. The fix doesn’t feel quite right to me, maybe it should go in core.js instead. I also haven’t exhaustively verified if the condition doesn’t have any side effects in other browsers, but it seems to not have an adverse effects in Safari, Chrome or Firefox.

I was wondering if anyone had a better idea or any input on dealing with this, or maybe any knowledge on when textInput events happen with data that’s more than a single character.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
lxcidcommented, Mar 6, 2017

I’m on another attempt to try to resolve this issue and I think I might find something of interest.

It seems that when iOS autocorrected you, the selection will wrap around the text. (isCollapsed == false)

If you try to retrieve the DOM selection during onBeforeInput, you be able to query it.

My hypothesis on why predictive text is duplicating is because the selection is not updated to overwrite the new changes.

I have to sign off for the day but I’ll try to research more tomorrow to confirm and see if I can come up with a fix.

0reactions
ianstormtaylorcommented, Apr 1, 2017

I believe this is fixed now!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use predictive text on iPhone - Apple Support
As you type text on the iPhone keyboard, Siri predicts your next word, based on your recent activity. Tap the word to enter...
Read more >
How to Turn on Predictive Text on an iPhone in 2 Ways
How turn on predictive text on an iPhone ; 1. Start the Settings app. ; 2. Tap "Keyboard." ; 3. On the Keyboards...
Read more >
How to Remove Words From iPhone Predictive Text - Lifewire
To turn on predictive text on an iPhone, open the Settings app and tap General. Tap Keyboard, and then tap the toggle next...
Read more >
How to Turn On Predictive Text on iPhone - How-To Geek
Select General > Keyboard in Settings. Scroll down the “Keyboards” page that opens to the bottom. · In the menu that opens, select...
Read more >
Too Many Autocorrect Fails? How to Tweak Your Keyboard ...
On your iPhone or iPad, go to Settings > General > Keyboard. Let's address the elephant in the room right off the bat....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found