Windows text suggestions append instead of replace in Slate editor
Description
On Windows, Slate editors don’t handle the OS/browser text suggestions correctly. When accepting a suggested completion, Slate inserts the entire suggestion without replacing the already-typed prefix.
Example: type He, click the suggestion Hello → the editor shows HeHello instead of Hello.
Steps To reproduce the behavior:
- Enable Windows “Text suggestions” feature (instructions: Enable text suggestions in Windows).
- Open the sandbox in Windows.
- Focus the Slate editor and type a partial word, e.g.,
He. - When the OS/browser shows a suggestion (e.g.,
Hello), click the suggestion with the mouse (or tap it on the suggestion bar).
Observe: the accepted suggestion is appended after the typed prefix → HeHello.
Expectation
Accepting an autocomplete suggestion should replace the current word’s prefix, yielding Hello in the example above, consistent with editors like Google Docs, Notion, and Medium.
Environment
- Slate Version: 0.111.0 (latest)
- Operating System: Windows 11 Pro, Version 23H2 (Build 22631)
- Browser: Google Chrome 127.0.6533.120 (64-bit)
- Input method: Hardware keyboard with Windows text suggestions enabled
Context
Likely related to how Slate handles composition or beforeinput events when the suggestion is inserted by the OS/browser. It may not be recognizing that the suggestion should replace the composing range rather than append at the caret.
Source: ianstormtaylor/slate