Don’t remove last char when deadkey is pressed. #30
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As I stated in #29, dead keys remove the last character of the input field. I included a gif bellow to show how to reproduce the bug (just type something, then input a dead key other than
1dk
).This is because when a deadkey is pressed, the event listner in
demo.js
is called twice in quick succession. It’s supposed to be called once, to delete the key hint the browser automatically writes (since x-keyboard gives way better hints), but the extra call also deletes another character.Logging those events (see gif, on the right hand side) shows they are basically the same, except the first event has the
isComposing
field set totrue
and the second one tofalse
.Removing the last char only when
event.isComposing
is set totrue
fixes that problem, and seems to be the only event we care about, if I understand MDN’s documentation correctly, though there may be an edge case I don’t know about (god knows JS has a lot of those…).