srm985/mok-project

number fields before text fields

Neilyroth opened this issue · 4 comments

Clicking a number field make the next text field I open "blank", then i cancel and open the text field again and it's content is there,
clicking a number field and the opening a textarea does not make the same result, so I assume it's a bug.
(chrome)

also the backspace on number fields seems to duplicate numbers and to append them at the start of the number if the field already has already a value.
(chrome and firefox)

the two bugs at once :
numbers

the append problem is linked to that javascript error

keyboard.js:1 Uncaught DOMException: Failed to set the 'selectionStart' property on 'HTMLInputElement': The input element's type ('number') does not support selection.
at s (keyboard.js:1:8154)
at HTMLButtonElement. (keyboard.js:1:12200)

Thanks so much for the detailed report! I was successfully able to reproduce the issue on my end. It was all definitely related to how I set the input field type. For any type of input field, I simply pass the type as a parameter to set the input type of the keyboard input field itself. The type 'number' was certainly causing issues. This alerted me to a much bigger issue at hand - I'm not checking input patterns or the min/max values so that I can enforce them while using the virtual keyboard. I made a quick fix and committed the changes. Inputs with type 'number' are now treated as type 'tel'. Currently in my keyboard, I treat type 'tel' and 'number' identical. I only allow users to enter characters 0-9 with no support for characters such as - + # . , or the numerous other options. So, if you are using input type 'number' because you'd like your users to be able to enter the characters 0-9, with no other characters or patterns defined, then the fix will solve your problem. If this isn't enough to work for now, I will work this evening to create a fix that accepts patterns and min/max parameters.

Additionally, I have been working on the option to initiate this keyboard as a smaller version that will open next to each clicked input field and will directly enter text into the selected field - thus removing all issues related to the input types.

thanks for that quick fix, i just changed my number fields to text, but as i want a positive integer without any restrictions for now, your update is perfect for me

keep up the good work !

Glad the quick fix works! I'm currently working on a more global resolution to the larger issue. I'll go ahead and close this issue but I've opened two additional issues to track the larger problems you helped me identify. Thanks again for the contribution and don't hesitate to open any other issues you might find.