forms icon indicating copy to clipboard operation
forms copied to clipboard

fix: Add support for adding new entries with IME input

Open Chartman123 opened this issue 1 year ago โ€ข 1 comments

This fixes #2220 by checking for isComposing state of the InputEvent

Duplicate code moved to QuestionMixin.js. The code changes in allow for adding new entries with IME input, specifically for languages like Japanese or Chinese. This improvement ensures a better user experience when using IME input methods.

Chartman123 avatar Jul 01 '24 08:07 Chartman123

@susnux any idea why watching isComposing now changes the behaviour from posting the first entered character to now posting an empty option and then trying to update it which then of course fails?

For testing you could try to enter an รฉ or รข or something like that...

Update: I was able to fix that by also checking if target.value !== '' (only needed for Linux/Mac for latin characters with accents: https://www.w3.org/TR/uievents/#keys-dead)

Update 2: With Chromium based browsers you need to press the space key two times to post the new option for IME languages. The Input event triggered with the first space still has isComposing === true so it looks like the compositionEnd is fired later than in Firefox.

Chartman123 avatar Jul 01 '24 22:07 Chartman123

@Chartman123 From mdn it seems that the input event is not guaranteed to be fired after composition ended but only on character input. Meaning probably the best is to listen to input and compositionend: Add new entry if:

  • input event with isComposing: false
  • compositionend event after an input event with isComposing: true

susnux avatar Jul 07 '24 17:07 susnux

Seems to work, but i find testing a bit hard

susnux avatar Aug 06 '24 16:08 susnux

Yeah, let's see what our users will say with the next release :)

Chartman123 avatar Aug 06 '24 16:08 Chartman123