Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

double the input content when in chrome using Microsoft ime lost focus #5653

Open
tsxuehu opened this issue May 18, 2024 · 1 comment
Open

Comments

@tsxuehu
Copy link

tsxuehu commented May 18, 2024

Description
on windows,in chrome, using microsoft ime,when lost focus,the input content will be doubled

Recording

20240518-152547.mp4

Sandbox
https://www.slatejs.org/examples/richtext

Steps

  1. on windows,using chrome open: https://www.slatejs.org/examples/richtext
  2. using Microsoft ime type chars
  3. click page any where
  4. see the content doubled

Expectation
the input content not doubled

Environment

  • Slate Version: 0.102.0
  • Operating System: win11
  • Browser: Chrome

Context
when lost focus while composition,chrome will produce two beforeinput event after compositionend event。

  1. beforeinput deleteContentBackward
  2. beforeinput insertText
    the compositionend and beforeinput(insertText) event make the content doubled
@tsxuehu
Copy link
Author

tsxuehu commented May 18, 2024

my project current solution:

  • record key down time stamp
  • in compositionend event handle:if has keydown during composition,but in last 100ms has no keydown,will ignore insert。
  • in beforeinput event handle:ignore Editor.deleteBackward and Transforms.select method call,when beforeinput timestamp is less then 100ms after last compositionend event。【when lost focus the beforeinput-deleteContentBackward has no meaning;event.getTargetRanges() is not accurate】

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant