Skip to content

Error field is not identified using color differences only #1914

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

Conversation

giacomo-petri
Copy link
Collaborator

Proposal for a new rule to check errors are not identified using color differences only.

Closes issue(s):

  • new rule

Need for Call for Review:
This will require a 2 weeks Call for Review


Pull Request Etiquette

When creating PR:

  • Make sure you're requesting to pull a branch (right side) to the develop branch (left side).
  • Make sure you do not remove the "How to Review and Approve" section in your pull request description

After creating PR:

  • Add yourself (and co-authors) as "Assignees" for PR.
  • Add label to indicate if it's a Rule, Definition or Chore.
  • Link the PR to any issue it solves. This will be done automatically by referencing the issue at the top of this comment in the indicated place.
  • Optionally request feedback from anyone in particular by assigning them as "Reviewers".

When merging a PR:

  • Close any issue that the PR resolves. This will happen automatically upon merging if the PR was correctly linked to the issue, e.g. by referencing the issue at the top of this comment.

How to Review And Approve

  • Go to the “Files changed” tab
  • Here you will have the option to leave comments on different lines.
  • Once the review is completed, find the “Review changes” button in the top right, select “Approve” (if you are really confident in the rule) or "Request changes" and click “Submit review”.
  • Make sure to also review the proposed Call for Review period. In case of disagreement, the longer period wins.

@giacomo-petri giacomo-petri added the Rule Use this label for a new rule that does not exist already label Sep 5, 2022
@giacomo-petri giacomo-petri self-assigned this Sep 5, 2022
@Jym77 Jym77 self-requested a review September 6, 2022 09:15
Copy link
Collaborator

@Jym77 Jym77 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work. There are still quite a bunch of precision to add to the Applicability and Expectation to meet the requirements of ACT rules 😃


## Applicability

This rule applies to any error field that is [visible][].
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is an "error field"? This needs an unambiguous and objective definition.


```html
<label for="first_name" style="color:#dd0000">First Name</label>
<input type="text" id="first_name" autocomplete="given-name" style="border:3px solid #dd0000" aria-invalid="true">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making it required would make it more obvious the reason why this is an error, especially with an explicitly optional field in the form. Makin the last name also required could make sense.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above


### Passed

#### Passed Example 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel we need examples that use something else than text inputs and other errors than absence of a required field. That can be both other built-in errors (check the list of constraint validation errors for inspiration); or custom errors (e.g. "password must contain at least 8 characters, …" that is usually checked by some script).

Notably, that would show that the rule also considers custom errors.
Also, I do believe that if built-in constraint validations are failing, the UA should automagically set aria-invalid (needs to be tested).

Copy link
Collaborator Author

@giacomo-petri giacomo-petri Sep 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated with different examples and added more details in what's failing.
See also my previous feedback about "required" and browser form validation (something to add in assumptions).

Comment on lines 93 to 96
<label for="first_name" style="color:#dd0000">First Name</label>
<input type="text" id="first_name" autocomplete="given-name" style="border:1px solid #dd0000" aria-invalid="true">
<label for="last_name" style="color:#333333">Last Name</label>
<input type="text" id="last_name" autocomplete="family-name" style="border:1px solid #b0b0b0" value="Doe">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be an example where the color difference is only on the field (the labels don't even have a color difference), and one where it is only on the label.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated keeping both label and border colors and added 2 failed examples for only label color and only input border color

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added also inapplicable example with hidden form.


### Inapplicable

#### Inapplicable Example 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be an example where there are only non-errored form fields.


```html
<p>This is a paragraph.</p>
```
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to add the reference list of the terms used in the rule.
For example, you use [visible][], so there should be here a definition:

[visible]: #visible 'Definition of Visible'

(see how it's done in other rules files

@giacomo-petri giacomo-petri requested a review from Jym77 September 26, 2022 10:23
Copy link
Collaborator

@Jym77 Jym77 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to define "visual context" (or find a way to do without it...)

Comment on lines 81 to 83
The email `input` value is missing the "@" symbol. Its visual error indicator (the first couple of `label` and `input` elements) conveyed the presence of an error through its CSS properties:
- lightness (difference in relative luminance between the colors leads to a contrast ratio greater than 3:1) AND;
- font-weight: bold.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The email `input` value is missing the "@" symbol. Its visual error indicator (the first couple of `label` and `input` elements) conveyed the presence of an error through its CSS properties:
- lightness (difference in relative luminance between the colors leads to a contrast ratio greater than 3:1) AND;
- font-weight: bold.
The email `input` value is missing the "@" symbol. Its visual error indicator (the first couple of `label` and `input` elements) conveyed the presence of an error through its CSS properties:
- lightness (difference in relative luminance between the colors leads to a contrast ratio greater than 3:1); and
- `font-weight: bold`.

I think it would make sense to have the different contrast being the only difference. Otherwise, tools or methodologies that ignore it but accept font-weight would still be considered consistent.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to maintain best practices to the passed example. Do you think could be acceptable to remove font-weight: bold from the passed example description, but keep it in the passed example code as per new edits?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also need to exert the rule to its limit (and the tools). Since the rule considers that a single difference is enough, we should have test cases with that, even if they are not best practice. This is part of the One thing at a time guideline in our design guide.
(actually, the case could even has a contrast ratio of exactly 3:1 to ensure that tools do accept that limit)
We can add to the background that while contrast alone is enough, it is a better practice to also use something else.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

font-weight removed and added a paragraph in background section.


## Applicability

This rule applies to any [visible][] [input error][] together with its visual context.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that "visual context" is objective enough for Applicability 🤔
(see the discussions we have on the "link context" definition)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Jym77,

I've removed the generic "visual context" with a more detailed list of elements that should be included in the evaluation.
I'm not sure about the "closest error message that refers to it" is objective enough.

@giacomo-petri giacomo-petri requested a review from Jym77 January 17, 2023 10:34
Jym77
Jym77 previously requested changes Jan 19, 2023

This rule applies to any [visible][] [input error][] together with:
- its [programmatic label]; and
- the closest error message that refers to it.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, "closest" is ambiguous. It could notably be distance in the DOM tree, or physical distance on screen between the painted elements.


This rule applies to any [visible][] [input error][] together with:
- its [programmatic label]; and
- the closest error message that refers to it.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also not sure that "error message" is unambiguous.
For example, putting a red cross next to errored field and a green check mark next to good ones, is a red cross an "error message" (it's not really a message)? (or the red border of Passed Example 3)


## Expectation

Each test target, together with its visual context, identify the presence of errors not only through color differences.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to change "visual context" here also.


## Applicability

This rule applies to any [visible][] [input error][] together with:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not fully convinced that "input error" is unambiguous enough.

information provided by the user that is not accepted

Does that mean that the field in which it was inputed is put in a validation error state? Or just that some code checked it and rejected it, without changing the validation state? Actually, this refers to the information, not even to the form field, is it what you want the rule to target?

- [Understanding Success Criterion 1.4.1: Use of Color](https://www.w3.org/WAI/WCAG21/Understanding/use-of-color.html)
- [F81 - Failure of Success Criterion 1.4.1 due to identifying required or error fields using color differences only](https://www.w3.org/WAI/WCAG21/Techniques/failures/F81.html)

It is possible for an error field to be distinguishable from adjacent fields but still not have a meaningful error message. In that case, it would pass Success Criterion 1.4.1: Use of Color but still fail [Success Criterion 3.3.1: Error Identification](https://www.w3.org/WAI/WCAG21/Understanding/error-identification.html) and, if applicable, [Scuccess Criterion 3.3.3: Error Suggestion](https://www.w3.org/WAI/WCAG21/Understanding/error-suggestion.html).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
It is possible for an error field to be distinguishable from adjacent fields but still not have a meaningful error message. In that case, it would pass Success Criterion 1.4.1: Use of Color but still fail [Success Criterion 3.3.1: Error Identification](https://www.w3.org/WAI/WCAG21/Understanding/error-identification.html) and, if applicable, [Scuccess Criterion 3.3.3: Error Suggestion](https://www.w3.org/WAI/WCAG21/Understanding/error-suggestion.html).
It is possible for an error field to be distinguishable from adjacent fields but still not have a meaningful error message. In that case, it would pass Success Criterion 1.4.1: Use of Color but still fail [Success Criterion 3.3.1: Error Identification](https://www.w3.org/WAI/WCAG21/Understanding/error-identification.html) and, if applicable, [Success Criterion 3.3.3: Error Suggestion](https://www.w3.org/WAI/WCAG21/Understanding/error-suggestion.html).


#### Passed Example 2

The "phone number" `input` value doesn't match the `type` value. Its visual error indicator (the first couple of `label` and `input` elements) conveys the presence of an error through its CSS properties:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This description uses "visual error indicator", which doesn't match the "error message" used in the Applicability. What does "visual error indicator" refers to?
(same on other descriptions)


#### Failed Example 1

The "first name" `input` value is empty. Its visual error indicator (the red border color of the first `input` element) conveys the presence of an error through color (hue) differences only.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add the contrast ratio with the other border color, to drive the nail in.


#### Inapplicable Example 1

There are no error fields.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These descriptions should talk about "input error", not "error field", in order to match the Applicability.

@giacomo-petri giacomo-petri dismissed Jym77’s stale review May 9, 2023 16:13

I've completely revised the rule by setting objective applicability and unambiguous expectation that should address all the remaining items you've listed above

@giacomo-petri giacomo-petri requested a review from Jym77 May 9, 2023 16:19
Copy link
Collaborator

@Jym77 Jym77 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to find a way to tell in the Expectation what we are comparing the errored field with.


## Applicability

This rule applies to each [HTML element][] that is [visible][] and has one of the following [semantic roles][]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This rule applies to each [HTML element][] that is [visible][] and has one of the following [semantic roles][]:
This rule applies to any [HTML element][] that is [visible][] and has one of the following [semantic roles][]:

Comment on lines +42 to +46
Each test target either has no [visible][] [form field error indicators][], or at least one of the [visible][] [form field error indicators][] identifies the presence of errors not only through color differences.

## Assumptions

When content is communicated using colors that vary not just in hue but also have a substantial difference in brightness, this constitutes an extra visual differentiation provided that the difference in the colors' relative luminance creates a contrast ratio of 3:1 or more.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we somehow need to put in the Expectation the fact that "contrast of 3:1 or more" is not a color difference.
We probably need to keep an assumption that this is indeed enough, but we also want to say in the "normative" part that the rule accepts this.


## Expectation

Each test target either has no [visible][] [form field error indicators][], or at least one of the [visible][] [form field error indicators][] identifies the presence of errors not only through color differences.
Copy link
Collaborator

@Jym77 Jym77 May 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing a potential pitfall here (also when looking at examples):
This somewhat implicitly consider that we have something to compare the error indicator to, in order to decide whether it is color differences or more (i.e. "differences" with what?)

This could either be another field, not in error, in the same form, or the same field when not errored.
The second solution somewhat requires a statefull rule and the tester to act (and put the field in error). This hopefully will be doable soonish (once we've solved #1953 / #2045), but that may still take time.
The first point could be doable by targeting pairs of field, passing if they are both errored or none errored, and comparing if only one is errored 🤔

Put otherwise: if there is only one form field in the page, and it is in error, how do we check the rule?

Copy link
Collaborator Author

@giacomo-petri giacomo-petri May 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could either be another field, not in error, in the same form

Comparing a pair of inputs, where one fails and the other does not, is not an optimal approach. Additionally, inputs may have different styles, such as checkboxes or text fields. Therefore, it is advisable to only compare inputs of the same type and with the same CSS.

Put otherwise: if there is only one form field in the page, and it is in error, how do we check the rule?

Limiting the rule to a specific pair of inputs (assuming the previous concern is addressed) would, in my opinion, be too restrictive.

I think we should go with the second option. @Jym77, should we put this rule on hold till #1953 / #2045 are solved?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a list worth bringing to attention that this is another rule proposal that would benefit from being statefull, so that we are sure the solution can handle it.

@WilcoFiers
Copy link
Member

Very out of date. Closing on behalf of @giacomo-petri

@WilcoFiers WilcoFiers closed this Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
manual rule Rule Use this label for a new rule that does not exist already
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants