Closed philsherry closed 2 years ago
I've also seen this happen with Dragon if a user pauses between numbers or letters. I've seen it come up a few times, and using blur()
as @philsherry suggested could be a nice solution for this particular instance.
However, I think there is a guidance or education piece which needs addressing around sanitising input data before validation as it will affect more than just the date component. I've seen it happen on bank account fields and National Insurance number fields, so it then becomes a bit of a can of worms trying to fix it for people rather than getting them to understand their own validation requirements. It also means you'd still have the issue if JS didn't load.
It almost feels like we should have patterns for this kind of thing. We have visual patterns and coded components, but we don't have common sanitisation, regex's, wording etc.
Having talked about this as a team, we think this is best addressed on the server-side by trimming or otherwise ignoring leading and trailing spaces as part of the validation process where appropriate. We think there'd be scope to add something about this to the 'Help users to recover from validation errors' pattern.
I've created an issue to represent this work – https://github.com/alphagov/govuk-design-system/issues/1450.
@philsherry it seems like this issue should be reported to Apple – have you raised a bug in Webkit / Radar?
@36degrees Just done.
To add - after testing, it's not just leading and trailing whitespace, but whitespace between the digits. Dictating with Voice Control I get 2 0 2 1
. I think this is probably rather unexpected and teams already stripping leading and trialing whitespace by default are unlikely to catch this.
It would be good to explicitly mention this on the date input component.
This is reported as having been fixed 'in shipping software' on the original Webkit bug as of February this year.
Testing it myself, following the steps outlined above, I am no longer seeing leading spaces nor spaces between characters when using Voice Control in Safari 15.5 (17613.2.7.1.8) on macOS 12.4 (21F79).
I think we can therefore close this issue as resolved. Thanks to @philsherry for taking the time to report it to us and to the Webkit team.
(I've also tested dictating 'two zero two one' and I get 2021
in the text input rather than 2 0 2 1
, so I believe that's been fixed too)
Issue: Voice Control inserts spaces in
input
fields. Platform: macOS 11.0.1 (20B29) Browser: Safari 14.0.1 (16610.2.11.51.8). (Only tested in the native browser, as other vendors will likely refuse to fix anyway.) Example page: Design System » Date input » Example Why: When the user inputs a value, Voice Control automatically inserts a leading space, leading to validation errors and a confused user. Suggest: Client-side trim of leading whitespace onblur()
Example 1: Input of a date on the example page:This actually tries to submit the following three values:
"11"
" 01"
" 2021"
☝️ Note the leading spaces in the inputs where Voice Control was used. Visually, they’re barely noticeable, but these will cause validation issues and force the error state. Here’s a screenshot from Safari’s web inspector, showing those values.
Example 2: Picking a country from the autocomplete:
Note: This issue doesn’t occur on mobile devices, but only because Voice Control completely refuses to see the inputs on the example page.