You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Checking keycodes for JavaScript input validation on the Number and Money fields isn't the best.
Steps to reproduce
On macOS, swap the keyboard layout to Hungarian.
On US-based QWERTY keyboards, the layout will look like this:
On non-US QWERTY keyboards, it'll look closer to:
Notice that the 0 is to the left of 1 on non-US QWERTY keyboards and doesn't exist on US QUERTY keyboards.
Trying to type the 0 on a non-US QUERTY keyboard won't input anything in a Number or Money field.
Typing CTRL-Option-0 is a workaround for both non-US and US QWERTY keyboards to get it to enter a 0 successfully.
Typing the three keys immediately to the right of 9 (on either a non-US or US QWERTY keyboard) will incorrectly let ö, ü, and ó pass validation and be entered into those fields (even though server-side validation fails because they are not numeric).
Relying strictly on keycodes in JavaScript isn't reliable across different keyboard layouts.
What happened?
Description
Checking keycodes for JavaScript input validation on the Number and Money fields isn't the best.
Steps to reproduce
Notice that the
0
is to the left of1
on non-US QWERTY keyboards and doesn't exist on US QUERTY keyboards.Trying to type the
0
on a non-US QUERTY keyboard won't input anything in a Number or Money field.Typing CTRL-Option-0 is a workaround for both non-US and US QWERTY keyboards to get it to enter a
0
successfully.Typing the three keys immediately to the right of 9 (on either a non-US or US QWERTY keyboard) will incorrectly let ö, ü, and ó pass validation and be entered into those fields (even though server-side validation fails because they are not numeric).
Relying strictly on keycodes in JavaScript isn't reliable across different keyboard layouts.
https://github.com/craftcms/cms/blob/develop/src/fields/Number.php#L258-L280
https://github.com/craftcms/cms/blob/develop/src/fields/Money.php#L254-L276
Probably worth checking the codebase for anywhere else we're checking for keycodes that need to consider localization.
Craft CMS version
4.3.4
PHP version
8.0
Operating system and version
macOS
Database type and version
n/a
Image driver and version
n/a
Installed plugins and versions
none
The text was updated successfully, but these errors were encountered: