nextcloud / forms

📝 Simple form & survey app for Nextcloud
https://apps.nextcloud.com/apps/forms
GNU Affero General Public License v3.0
316 stars 97 forks source link

fix: Add support for adding new entries with IME input #2232

Closed Chartman123 closed 1 month ago

Chartman123 commented 2 months ago

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

Duplicate code moved to QuestionMixin.js. The code changes 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 commented 2 months ago

@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.

susnux commented 2 months ago

@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:

susnux commented 1 month ago

Seems to work, but i find testing a bit hard

Chartman123 commented 1 month ago

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