jcorporation / myMPD

myMPD is a standalone and mobile friendly web mpd client with a tiny footprint and advanced features.
https://jcorporation.github.io/myMPD/
GNU General Public License v3.0
421 stars 66 forks source link

Finishing IME composition with Enter key also clears the search box #977

Closed soya-daizu closed 1 year ago

soya-daizu commented 1 year ago

myMPD version: 10.2.2

Describe the bug

Users in CJK regions use IME (Input Method Editor) to input text in their languages. IMEs have their own input state that is separate from the text box, and use Enter key to "exit" the composition and enter the composed text into the text box.

In Firefox, the keyup and keydown events are also fired during IME composition, meaning that the Enter key that is pressed to finish the composition also triggers myMPD's Enter key behavior in the search box.

This produces undesirable effect that "enters" the filtering condition before user inputs all filtering words if they finish composition in the middle of the text.

This issue does not appear in Chrome as it doesn't fire Enter key events with keyup during IME composition.

To Reproduce

Steps to reproduce the behavior:

  1. Go to "Browse" or "Search" tab
  2. Click on the search box
  3. Start typing with IME
  4. Enters the composed text with the Enter key

Expected behavior

It should not clear the search box and enter the filtering condition below the search box. Users should only be able to enter search conditions and clear the search box after the IME composition is ended.

Server plattform (please complete the following information):

Client plattform (please complete the following information):

Additional context

One solution is to use the event.isComposing property, but myMPD seems to be using keyup instead of keydown to detect key presses, and event.isComposing with Enter key can only be true in the keydown events.

Is using keyup instead of keydown necessary to produce the current behavior?

If we are sticking with keyup, there are events specific to IME composition like compositionstart and compositionend, so maybe we can hold the composition state in the back and ignore the Enter keyup while that state is true.

jcorporation commented 1 year ago

How can I use the IME input method. I even do not know that IME exists.

soya-daizu commented 1 year ago

It's straight forward on Windows and macOS but it can be tricky in some Linux distributions. Here are some guides I found about installing Japanese input methods for example.

Linux https://wiki.archlinux.org/title/Input_method Windows https://www.coscom.co.jp/learnjapanese801/install_ime.html macOS https://support.apple.com/guide/japanese-input-method/welcome/mac

As for installing IMEs on Arch based distributions, I would recommend the fcitx5-mozc package. There should be similarly named packages in other major distributions as well. Fcitx5 is like a frontend for different IMEs and Mozc is the actual IME behind it.

If these are too much of work for you and you don't mind not being able to verify the patch, I can try to fix it and make a PR for it.

jcorporation commented 1 year ago

If these are too much of work for you and you don't mind not being able to verify the patch, I can try to fix it and make a PR for it.

That would be great!

jcorporation commented 1 year ago

Merges! Many thanks for the PR.