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

IME input compatible #397

Closed
wants to merge 1 commit into from
Closed

IME input compatible #397

wants to merge 1 commit into from

Conversation

new-sankaku
Copy link
Contributor

The following issues have been fixed.
I wrote the problem in an issues.
IME input compatible #396

I've made a correction regarding an issue that caught my attention, although JavaScript is not my specialty. However, from what I've tested with Japanese and English inputs, it seemed to work without any problems.

The correction is as follows:
When IME input begins, a compositionstart event is called, and when it ends, a compositionend event is called. For IME inputs, since the Input event stores the entire string in the buffer, I've concatenated the pre-held string before input and the string being input, replacing everything accordingly. There might be a better method, but I believe replacing everything should not be particularly heavy processing.

The issue is as follows:
The text input needs to be compatible with IME string input.

Here's a brief overview of the problem:
For languages like English, strings are directly input into the Input field. However, for some languages (such as Japanese and Chinese), input is done through an IME. The IME treats the input string as a buffer. Since this buffer passes the entire string being input each time the input event is called, the current process results in the string being displayed in duplicate.

For example, when typing "ABC", the Input fires events for "A", "AB", "ABC". As a result, "AABABC" is entered on the screen (this example uses English characters for illustration purposes). This can be critical for countries that standardly use an IME.

The correction is as follows:
When IME input begins, a compositionstart event is called, and when it ends, a compositionend event is called. For IME inputs, since the Input event stores the entire string in the buffer, I've concatenated the pre-held string before input and the string being input, replacing everything accordingly. There might be a better method, but I believe replacing everything should not be particularly heavy processing.
@viliusle
Copy link
Owner

I included your PR manually (wanted to ignore dist/* files).

@viliusle viliusle closed this Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants