-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
value change should not trigger when typeing ( compositionstart -> compositionend ) #13196
Comments
What exactly are you referring to? |
I'm assuming this is for Having worked on Lexical, I can tell you that it's really difficult to get IME input correct. Listening to If you want to reliably capture text input yourself, it's recommended that you use a rich text library such as ProseMirror or Lexical instead of trying to do it yourself. |
If you imply that the semi-composed text is meaningless, then the same can be said about the unfinished word or sentence/query.
A reminder: for the text fields, the
|
I'm writing a real-time search that will trigger the search when the user enters new content. If the user does not enter the complete content using the Chinese input method, then the value binding should not trigger the search. If using vue, the performance is as expected, but using svelte is not. |
What element is the search? |
input |
I tested it on my Mac. When inputting Chinese, using shortcut keys to paste does not work. Pasting with the mouse will cause the focus to be lost and trigger a change event. For me, triggering a value modification check on both compositionend and input works as expected. |
|
Different IMEs can have vaguely different behaviour. Mine does allow pasting while in composing. I remember debugging a VSCode problem with the Also, not everyone wants this "value change not triggering during composition". Changing this behaviour is a weird breaking change in my opinion. I think you can manually handle it on your own with |
Does svelte have something similar to vue's Modifiers? https://v2.vuejs.org/v2/guide/forms.html#Modifiers If there is such a thing, it can be more convenient to customize the behavior of bind:value or else , define new bind, for example: bind:valime |
Svelte doesn't have modifiers. <input bind:value on:compositionstart={() => composing = true} on:compositionend={() => composing = false} /> and do nothing when |
Describe the problem
https://developer.mozilla.org/en-US/docs/Web/API/Element/compositionstart_event
When using the input method, the user has not formally entered text and the value change event should not be triggered.
You can refer to the implementation in vue
https://github.com/vuejs/core/blob/main/packages/runtime-dom/src/directives/vModel.ts
now svelte is
Describe the proposed solution
When the user starts inputting Chinese characters using the Pinyin input method, the compositionstart event will be triggered. When the composition of a text paragraph is completed or canceled, the compositionend event will be fired.
That is to say, when we start inputting Chinese, a compositionstart event will be triggered. During the Chinese input process, the compositionstart event will not be triggered again. Finally, the compositionend event will be triggered when the Chinese input is completed.
And after experiments, it was found that when inputting Chinese, compositionstart is triggered before the input event.
Importance
nice to have
The text was updated successfully, but these errors were encountered: