hodgef / simple-keyboard

Javascript Virtual Keyboard - Customizable, responsive and lightweight
https://virtual-keyboard.js.org/
MIT License
2.22k stars 170 forks source link

After typing the first character in the middle of the text, the input jumps to the end #2346

Closed joao-mbn closed 1 month ago

joao-mbn commented 1 month ago

Describe the bug Identical to #1839

I found it using react-simple-keyboard@3.7.153, but it happens in the demo page as well

Provide a repro

  1. Go to: https://hodgef.com/simple-keyboard/demos/
  2. Type anything in the input, like "AAAA"
  3. Put the caret at the second position
  4. Click "1" at the keyboard twice
  5. See that the string is "AA1AA1" instead of "AA11AA"
hodgef commented 1 month ago

Hello @joao-mbn,

Indeed the issue you linked is relevant. This issue was caused by the selectionchange event which was reporting a wrong caret position. The issues with this event were limited to Firefox, but now I believe there has been a change to Chromium as well which added this regression.

I've removed this listener. For folks who want the old behavior back, there's the new option: updateCaretOnSelectionChange: true.

The fix is part of v3.8.0 release and should make it into react-simple-keyboard in a few minutes.

Thanks and let me know if you still experience issues, Francisco Hodge

joao-mbn commented 1 month ago

Thank you very much @hodgef. I updated the version and it is working as expected now.