question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Focused inputs, textareas and file uploads may not have enough contrast when in the 'error' state

See original GitHub issue

For 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.

May-29-2020 16-09-11

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
christopherthomasdesigncommented, Jun 18, 2020

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.

Screenshot 2020-06-17 at 13 51 04

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:

Screenshot 2020-06-17 at 14 47 26

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:

Screenshot 2020-06-17 at 13 51 29

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:

Screenshot 2020-06-17 at 15 16 27

I guess I’m saying I think I’ve solved it but would be good to know:

  • if there are things I haven’t considered
  • any impacts you could see these changes having on other patterns or components
1reaction
MalcolmVonMoJcommented, Jun 23, 2020

Here is the page as it appeared when the research was done, warts and all.

image

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found