mui / mui-x

MUI X: Build complex and data-rich applications using a growing list of advanced React components, like the Data Grid, Date and Time Pickers, Charts, and more!
https://mui.com/x/
4.07k stars 1.26k forks source link

[pickers] When the IME is in hiragana, the input on the numeric keypad is wrong. #9465

Open kawa0102 opened 1 year ago

kawa0102 commented 1 year ago

Duplicates

Latest version

Steps to reproduce ๐Ÿ•น

I have a problem when using a Japanese keyboard. And this defect was also confirmed by https://mui.com/x/react-date-pickers/date-picker/. And this defect was also confirmed by https://mui.com/x/react-date-pickers/time-picker/.

I'm sorry,I explained it badly.

Steps: 1.Use the full/half-width key to set the IME to "ใฒใ‚‰ใŒใช". ใ‚ญใƒผใƒœใƒผใƒ‰ใฎๅŠ่ง’ๅ…จ่ง’ๅˆ‡ใ‚Šๆ›ฟใˆใ‚ญใƒผ

2.focus on the input field.(Make sure the IME is set to "ใ‚.") ๅ›ณ1

3.press "1" on the numeric keypad.(any number is fine.) S1004271075395_OUT_keyboad2

4."11" appears in the input field.

Current behavior ๐Ÿ˜ฏ

I have a problem when using a Japanese keyboard.

When "1" is pressed on the numeric keypad, "1" should appear in the input field. However, if you press "1" when the number is full-width, the input field will display "11". After repeating the process many times, the input becomes incorrect.

When I pressed the numeric keypad in full-width characters, I confirmed that onChange was working three times.

https://github.com/mui/mui-x/assets/137742480/f97126a9-bc33-462f-90dd-612f2bbcac30

Expected behavior ๐Ÿค”

When I press a numeric keypad in full-width characters, I want the number I press to be displayed in the input field.

Example: Press "1" โ†’ "1" appears in the input field.

Context ๐Ÿ”ฆ

In Japan, hiragana is often used, the display will frequently be incorrect if it is not changed.

Your environment ๐ŸŒŽ

@mui/x-data-picker: v6.9.0

System: OS: Windows 10 10.0.19042 Binaries: Node: 16.17.1 - C:\Program Files\nodejs\node.EXE Yarn: Not Found npm: 8.15.0 - C:\Program Files\nodejs\npm.CMD
Browsers: Chrome: 114.0.5735.134 Edge: Spartan (44.19041.1023.0), Chromium (114.0.1823.58) npmPackages: @emotion/react: ^11.11.1 => 11.11.1 @emotion/styled: ^11.11.0 => 11.11.0 @mui/base: 5.0.0-beta.4 @mui/core-downloads-tracker: 5.13.4 @mui/material: ^5.13.5 => 5.13.5 @mui/private-theming: 5.13.1 @mui/styled-engine: 5.13.2 @mui/system: 5.13.5 @mui/types: 7.2.4 @mui/utils: 5.13.1 @mui/x-date-pickers: ^6.9.0 => 6.9.0 @types/react: ^18.0.24 => 18.0.24 react: ^18.2.0 => 18.2.0 react-dom: ^18.2.0 => 18.2.0 typescript: ^4.8.4 => 4.8.4

Order ID or Support key ๐Ÿ’ณ (optional)

No response

LukasTy commented 1 year ago

@mui/explore Could anyone on Windows test this? I'm having trouble installing a Japanese keyboard on a Windows emulator, and I couldn't reproduce the issue on MacOS. ๐Ÿคท

noraleonte commented 1 year ago

I can't really reproduce the issue on Windows either ๐Ÿค”

kawa0102 commented 1 year ago

Windowsใงใ‚‚ๅ•้กŒใ‚’ๅฎŸ้š›ใซๅ†็พใงใใพใ›ใ‚“๐Ÿค”

I'm sorry. Some of the instructions on how to reproduce were incorrect and I have corrected them.

kawa0102 commented 1 year ago

@mui/explore Could anyone on Windows test this? I'm having trouble installing a Japanese keyboard on a Windows emulator, and I couldn't reproduce the issue on MacOS. ๐Ÿคท

I'm sorry. Some of the instructions on how to reproduce were incorrect and I have corrected them.

alexfauquette commented 1 year ago

Maybe related to react having issues about IME https://github.com/facebook/react/issues/3926

I'm not on windows, but maybe a way to reproduce it could be to look at the onChange triggered when you are pressing 1.

If you go there (a simple input field with an onChange) and with the problematic keyboard configuration could you select a section with your mouse (select 2 digits) and press 1.

Here is the result on my computer. Each time I press 1 the onChnage is called once with the selected section replaced by 1. In your case the onChange will probably be called twice or with extra character

https://github.com/mui/mui-x/assets/45398769/618d59aa-2f9d-41d0-b7c3-3a6827c4889c

kawa0102 commented 1 year ago

Maybe related to react having issues about IME facebook/react#3926

I'm not on windows, but maybe a way to reproduce it could be to look at the onChange triggered when you are pressing 1.

If you go there (a simple input field with an onChange) and with the problematic keyboard configuration could you select a section with your mouse (select 2 digits) and press 1.

Here is the result on my computer. Each time I press 1 the onChnage is called once with the selected section replaced by 1. In your case the onChange will probably be called twice or with extra character

Screencast.from.30-06-2023.13.22.47.mp4

I checked and this is how it works.

https://github.com/mui/mui-x/assets/137742480/75566989-7e66-46a3-9533-32ded738ece8

alexfauquette commented 1 year ago

Thanks for the recording. Sounds like pressing a key leads to 3 onChange. The first is correct, the second deletes everything after and the last add the digit at the end.

That sounds quite hard to handle ๐Ÿคจ

kawa0102 commented 1 year ago

้Œฒ้Ÿณใ—ใฆใใ‚Œใฆใ‚ใ‚ŠใŒใจใ†ใ€‚ใ‚ญใƒผใ‚’ๆŠผใ™ใจ 3 ใซใคใชใŒใ‚‹ใ‚ˆใ†ใซ่žใ“ใˆใพใ™onChangeใ€‚1 ใค็›ฎใฏๆญฃใ—ใใ€2 ใค็›ฎใฏใใ‚Œไปฅ้™ใ‚’ใ™ในใฆๅ‰Š้™คใ—ใ€ๆœ€ๅพŒใฏๆœ€ๅพŒใซๆ•ฐๅญ—ใ‚’่ฟฝๅŠ ใ—ใพใ™ใ€‚

ใ‹ใชใ‚Šๆ‰ฑใ„ใŒ้›ฃใ—ใใ†ใงใ™ใญ๐Ÿคจ

When the IME is set to "Hiragana", the operation is strange even if I press anything other than the numeric keypad. Even if onChange does not move, the value displayed will be wrong. And the cursor position changes.

https://github.com/mui/mui-x/assets/137742480/30087386-fecf-4c99-800f-30010c7b698d

alexfauquette commented 1 year ago

@flaviendelangle From some investigation, it seems this behavior is named composition similar to what we do when we creating letters such as รซ

It triggers a compositionStart and compositionEnd event. I wonder if it's similar issue that occurs on Android with windows keyboard. If yes it could be the opportunity to fix both with the same code base

The compositionend event is fired when a text composition system such as an input method editor completes or cancels the current composition session. https://developer.mozilla.org/en-US/docs/Web/API/Element/compositionend_event

A workaround found: https://github.com/facebook/react/issues/3926#issuecomment-1200414788

oliviertassinari commented 1 year ago

It reminds me a bit of https://github.com/mui/material-ui/pull/19499, but it's different here.