Slate: [IME] Wrong character deletion after inputting Japanese character

Created on 10 May 2017  ·  2Comments  ·  Source: ianstormtaylor/slate

Do you want to request a feature or report a bug?

bug

What's the current behavior?

I found that the character next to the cursor is wrongly deleted when I input a Japanese character.
(maybe it also occurs in some other multibyte languages...?)

I looked into the code and figured out this part of the core plugin causes it.
But the fundamental problem is anchorOffset and focusOffset returned by native window.getSelection() is different in each browsers.

I tested the behavior by inputting Japanese character into the sentence below. (| is cursor)

A line of text in a para|graph.

The result is so strange:

| Browser | anchorOffset | focusOffset |
|----|----|----|
| Expected | 24 | 24 |
| Safari (iOS/Mac) | 24 | 24 |
| Chrome 58 (Mac/Win) | 24 | 25 |
| Firefox 53 (Mac/Win) | 25 | 25 |
| IE 11 (Win) | 25 | 25 |

I think it's hard to fix, but it's a fact that the fix only for iOS affects Japanese input unexpectedly.
So my suggestion is checking platform before updating the selection.

What's the expected behavior?

I can submit PR if my suggestion is accepted.

bug ⚑ ime

Most helpful comment

Hi @questbeat, could you add _[IME]_ to the title of this issue? It makes it easier to round up bugs related to IMEs by a simple search. I want to help get to the bottom of the problem, and this would help a lot!

All 2 comments

Hey @questbeat, thanks for investigating this. I honestly don't know enough about how other language character input works to be able to debug well. I tried making it work in the past but I'm sure it's regressed since then. I'd love PR's that help fix it—as long as they don't break the existing behaviors. Thank you!

Hi @questbeat, could you add _[IME]_ to the title of this issue? It makes it easier to round up bugs related to IMEs by a simple search. I want to help get to the bottom of the problem, and this would help a lot!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ezakto picture ezakto  ·  3Comments

markolofsen picture markolofsen  ·  3Comments

ianstormtaylor picture ianstormtaylor  ·  3Comments

yalu picture yalu  ·  3Comments

AlexeiAndreev picture AlexeiAndreev  ·  3Comments