Focused inputs, textareas and file uploads may not have enough contrast when in the 'error' state
See original GitHub issueFor the input and textarea components, we rely on the input border getting thicker in order to meet WCAG 2.1 1.4.11: Non-text Contrast.
When the text input or textarea is in the error state, it already has a thicker border, and so the border only changes from red to black (in addition to the yellow outline). ~The contrast between the red and the black is only 2.75:1.~ EDIT: The contrast between the red (#d4351c
) and black (#0b0c0c
) is 4.03:1 – see https://github.com/alphagov/govuk-frontend/issues/1820#issuecomment-698253481.
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (10 by maintainers)
Top Results From Across the Web
[MDCTextField] Error state disappears after focus out #5620
Bug report. If input has error state active, after input focus out the error state seems to disappear.
Read more >WCAG 2.1 Standard: Summary - HTML_CodeSniffer
Specifically tested are input, select and textarea elements. Labels can only be associated with form controls, not generically with other elements. H44. Error...
Read more >4.10 Forms — HTML5
The textarea element can be used to provide a free-form text field. ... When an input element's type attribute is in the File...
Read more >Accessibility Guide for Developers
Accessbility best practices, guidelines, and testing tools geared toward developers when creating accessible forms with Gravity Forms.
Read more >File Upload validation focus
When a File Upload is required but not completed and the submit button is clicked, the validation error shows as red "Value is...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Had a little look into this.
I think we can mostly solve this problem by reducing the error border width on inputs down to 2px. Fields with an error would continue to be differentiated from others by the thicker left border and bold error text. The red colour of the input border can be seen as an enhancement, same as the other elements.
Then when you focus it, the existing wider black border makes it clear that it’s being focused.
On the file upload error specifically, it seems like it would work fine without another border surrounding the button anyway:
The only example where I’m not sure this works is something like a date input. Here you can have a group of related fields that share an error message, but where only one field has an error. The current styling means the errored field is differentiated from others by a thicker border. That’s lost when you use a 2px border, where only the red colour makes it different:
This might not be a big problem though. In the case above the error message specifically says which field has an error, ~and it is the only field without any saved data in it~. You could add a bit of extra emphasis to the errored field by bolding its label though:
I guess I’m saying I think I’ve solved it but would be good to know:
Here is the page as it appeared when the research was done, warts and all.