Improve input handling for room short ID
The pattern for validation now allows any whitespace charaters besides numbers. Previously, short IDs copied from other views were not accepted because of the thinspace character.
The handler has been rewritten and now is based on InputEvent
s instead
of KeyboardEvent
s. It now prevents inserting any non-numeric chars.
Furthermore, it no longer blocks key events when the the maximum length
has been reached. Instead, the limit is enforced by removing any chars
which would exceed it.
This fixes the following issues:
- Non-numeric chars could be entered.
- Some control keys or combinations had no effect when the limit is reached which might impact a11y (e.g. arrow keys, Ctrl+A, Home, End, Delete).
- The length limit was not always enforced (e.g. when pasting text).
A separate handler for beforeinput
events is used to prevent the
default action when the length limit has been reached. In contrast to
the ìnput
event, its specification is quite new and only supported by
current browser versions. This is a minor UX enhancement, so the field
is still fully functional if the handler cannot be used.
Related: !1055 (merged)