-
Notifications
You must be signed in to change notification settings - Fork 319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Focused inputs, textareas and file uploads may not have enough contrast when in the 'error' state #1820
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, I guess I'm saying I think I've solved it but would be good to know:
|
@christopherthomasdesign Our user researcher found the following:
If we reduce the thickness of the border to that of a normal input box, it would make the error state jump out less. This might lead to more instances of that found in our tests. I appreciate we tested with black boxes not red, but as mentioned at the top, the contrast betwixt the two is not great. |
Hi @MalcolmVonMoJ thanks for your comment, that's really useful. Would you be able to share a screenshot of what those errored fields look like in the context of a page? Thanks! |
As I continue to work on our error messages, a thought occurred to me. An error-state box, when focussed could reduce the thickness of the box. The change would be discernible through change in thickness, so the problem is solved. This would make an error & focussed state similar thickness (minus yellow) to a non-error & non-focussed state, but you cannot go direct from one to the other, so no-one is relying on that being different. Here are a few mockups I created to sanity-check the idea. CSS changed from With an extra bit of CSS for error and focussed for the design with the red box. |
Thanks again for your input @MalcolmVonMoJ! I've taken what you've done and looked at a number different border widths combinations to try solve this problem. I prototyped different styles with some of the relevant components to quickly see how they'd work (username:design password:mess):
I'll outline a few thoughts about each below. We'll probs have a team discussion to weigh up the pros and cons but any other input or feedback would be really useful. 1. 2px error outline with 4px focus highlightThe errored input doesn't contrast enough with standard inputs when not focused. 2. 4px error outline with 2px focus highlight(I think this is closest to the ideas above). Errors stand out visually when not focused. When focused they lose contrast with other non-focused inputs as the yellow border is the only differentiator. 3. 4px error outline with 6px focus highlightFocus state on errors has sufficient contrast with both the errored state and regular inputs. Visually very heavy but doesn't impede readability of the data users enter (though I say this as a fully sighted person). 4. 4px error outline with 6px focus highlight in redSame pros and cons as above. These components would be the only cases where the focus state doesn't consist only of yellow and black. Given how much work went into defining the focus states it seems not worth diverging from if option 3 works. 5. 6px error outline with 4px focus highlightHas enough contrast between all the states. Visually the 6px input border is a little inconsistent with the 5px error border on the left. There are probably more ways to do this but these were the simplest I could think of. I'd say number 3 is my favoured option. It's in-keeping with the 'additive' nature of how we style focus states elsewhere. BUT very much open to any drawbacks I haven't thought of or new suggestions. |
My preference would be to avoid having a different focus state for inputs in the error state, which I think would point to option 1 or option 5. I think it's important to keep the 'rules' simple, for a couple of reasons:
Out of the two options, I think I'd lean towards 1, because the transitional behaviour ("borders get thicker when focused") is consistent with non-error'ed fields, as well as the individual error and focus states. As previously mentioned, this does mean that in form groups with multiple fields (like the date input) the field cannot be visually identified unless you can perceive the difference between the black and the red, but in the examples in the Design System the error message should also identify which field is problematic. Other cases where the error message can't provide that context seem to be hypothetical at this point, and I wonder whether we can mitigate against that by:
If we do end up preferring one of the options where the focus state is different for error'ed fields, I'd like us to try and do research with users with autism and/or engage with accessibility experts with a good understanding of how users with autism might be affected by the perceived inconsistency. |
Had a chat with @timpaul about this and agree with your comments @36degrees. As a principle I think it makes sense to keep focus styles the same in all contexts if we can. In light of that I've made a draft PR alphagov/govuk-design-system#1302 that:
Have a look at the preview, particularly the changed guidance on: Next steps, we probs need to:
|
Summary of team discussion 13 July 2020
|
We've realised since shipping that this feature that this is incorrect – unfortunately this is based on the contrast between the 'old' red ( The contrast between the current red ( Although 4.03:1 technically meets the 3:1 ratio required for WCAG 2.1 1.4.11: Non-text Contrast, we still think that on balance this was the right change to make, an it does significantly improve the visibility of the focus state on fields in the error state. We have since updated the order of the colour palettes in the settings file to make similar mistakes less likely (#1901). I'll update the original message to reflect this. |
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 #1820 (comment).The text was updated successfully, but these errors were encountered: