Skip to content
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

Amendments to button and image button rules #1184

Closed
wants to merge 6 commits into from

Conversation

EmmaJP
Copy link
Collaborator

@EmmaJP EmmaJP commented Feb 22, 2020

Following decisions in conversation raised by #1049, this PR combines rules regarding buttons and image buttons having an accessible name, and creates a new rule about whether the accessible name of an image button describes its purpose.

When reviewing, please also point out any out of dates formats or phrasing. I have tried to adjust those as I've worked.

Issue(s):

Need for Final Call:
This will require a 2 week Final Call, as it includes a new rule.


Pull Request Etiquette

When creating PR:

  • Make sure you're requesting to pull a branch (right side) to the develop branch (left side).

After creating PR:

  • Add yourself (and co-authors) as "Assignees" for PR.
  • Add label to indicate if it's a Rule, Definition or Chore.
  • Close the issue that the PR resolves (and make sure the issue is referenced in the top of this comment)
  • Optionally request feedback from anyone in particular by assigning them as "Reviewers".

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 Final Call period. In case of disagreement, the longer period wins.

@EmmaJP EmmaJP added reviewers wanted Rule Update Use this label for an existing rule that is being updated labels Feb 22, 2020
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 job!
I think the first rule ("non empty accessible name") is now a bit "heavy" with the image button examples. The point is to not single them out so we maybe don't need to insist that image button are buttons (input with a type in the Button/Reset Button/Submit Button states are also buttons but we don't have any examples of these, typically)

_rules/button-accessible-name-97a4e1.md Outdated Show resolved Hide resolved
Comment on lines 26 to +29
**Note:** `input` elements have a `type` attribute in the `Image button` state if it is set to any case-insensitive match of `image` (most of the time, using `<input type="image">`).

**Note:** The specification of the [`type`](https://html.spec.whatwg.org/#states-of-the-type-attribute) attribute describes in detail how to map the value of the attribute to its corresponding state.

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 both these notes can now go away.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Are either of these notes required later in regard a specific example. Required for understanding, as opposed to nice-to-have.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If they are only required for understanding an example or two, they should probably be moved to the description of these examples. With the new applicability which has nothing to do with type or Image button, they look completely out of the place and it is not clear why a rule about buttons need this (for example, why precising how to put an input in the Image button state, but not precise how to put it in the Button, Reset Button or Submit Button state? And why even mention input elements on a rule about buttons?)

Comment on lines +211 to +234
#### Failed Example 5

This `input` element with 'type' attribute in the `Image button` state has an empty [accessible name][]. The `name` attribute can not be used to provide an [accessible name][].

```html
<input type="image" name="search" src="/test-assets/shared/search-icon.svg" />
```

#### Failed Example 6

This image button has an empty `alt` attribute, and no other attributes that can give it an [accessible name][].

```html
<input type="image" src="/test-assets/shared/search-icon.svg" alt="" />
```

#### Failed Example 7

This image button has an `aria-labelledby` attribute, but the referenced element does not exist. This gives the button an empty [accessible name][].

```html
<input type="image" src="/test-assets/shared/search-icon.svg" aria-labelledby="non-existing" />
```

Copy link
Collaborator

Choose a reason for hiding this comment

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

These examples might be hitting the corner case of the HTML AAM overloading the accessible name computation:
https://www.w3.org/TR/html-aam-1.0/#input-type-image (step 4)
Can you try and run some tests on major browsers to check what they do?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This example in Chrome and Safari, defaults to a submit button programmatically. If the image doesn't load, the word 'Submit' will become the button text.

Copy link
Collaborator

Choose a reason for hiding this comment

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

So, the description of "empty accessible name" is not correct. And these examples do not actually fail this rule (they fail the other rule given that the name is not descriptive).

The `button` element is tested separately from the `img` element. [Success Criterion 4.1.2 Name, Role, Value](https://www.w3.org/TR/WCAG21/#name-role-value) is applied to the button, whereas the image is tested under [Success Criterion 1.1.1 Non-text Content](https://www.w3.org/TR/WCAG21/#non-text-content)

```html
<button><img src="/test-assets/shared/search-icon.svg" alt="Search" /></button>
Copy link
Collaborator

Choose a reason for hiding this comment

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

The button element still has a semantic role of button and thus is applicable for the rule.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Would this code ever be considered an image button? Or is it a failed example?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not an image button as per the sense "input element in the Image Button state".
But this is the rule checking that elements with role of button have a (non empty) accessible name. In that case, there is an element with a role of button (the button element itself), thus the rule is applicable and passes because the button element gets its name from the content, here the, alt attribute of the image (iirc).

_rules/button-accessible-name-97a4e1.md Outdated Show resolved Hide resolved
Comment on lines 103 to +121
#### Failed Example 1

The image button element has an empty [accessible name][]. The `name` attribute can not be used to provide an [accessible name][].
This `input` element with 'type' attribute in the `Image button` state has an empty [accessible name][], which cannot be descriptive. The `name` attribute does not provide an [accessible name][].

```html
<input type="image" name="search" src="/test-assets/shared/search-icon.svg" />
```

#### Failed Example 2

The image button has an empty `alt` attribute, and no other attributes that can give it an [accessible name][].
This image button has an `alt` attribute that is not descriptive as the [accessible name][].

```html
<input type="image" src="/test-assets/shared/search-icon.svg" alt="" />
<input type="image" src="/test-assets/shared/search-icon.svg" alt="Share" />
```

#### Failed Example 3

The image button has an `aria-labelledby` attribute, but the referenced element does not exist. This gives the button an empty [accessible name][].
The image button has an `aria-labelledby` attribute, but the referenced element does not exist. This gives the button an empty [accessible name][], which cannot be descriptive.
Copy link
Collaborator

Choose a reason for hiding this comment

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

As with the other rule. These may actually have an accessible name according to the AAM.
OTOH, this is probably easier to get failed examples here given that the default name is "Submit Query"…

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 guess in this instance the default would not be descriptive.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, but the description should say so rather than saying that it has an empty accessible name.

Comment on lines +147 to +155
This `button` element is separate from the `img` element.

```html
<button><img src="/test-assets/shared/search-icon.svg" alt="Search" /></button>
```

#### Inapplicable Example 4

The `img` element is not a user interface component, and so is not tested for [Success Criterion 4.1.2 Name, Role, Value](https://www.w3.org/TR/WCAG21/#name-role-value).
This `img` element is not button component.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Description of these two examples could also be in the line of "There is no input element in the Image button state" (to match applicability more closely). Likely adding the extra explanation as second sentence.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Could you provide some suggestions so I can better understand what you mean. Thanks.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The rule is applicable to input elements in the Image Button state. So the reason that these snippets are inapplicable is the lack of such elements. It has nothing to do with button elements or components. To match the example description syntax, both these should be
"There is no input element in the Image Button state."
An extra sentence can be added. Maybe for Inapplicable Example 3 "A button element containing only an img element is not an Image Button, this rule specifically checks for input elements in the Image Button state". And for Inapplicable Example 4 "The img element alone is not an Image Button."

Co-Authored-By: Jean-Yves Moyen <jym@siteimprove.com>
This image button has an [accessible name][] through the `aria-label` attribute.

```html
<input type="image" src="/test-assets/shared/search-icon.svg" aria-label="Search" />
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure this adds anything not already covered in Passed Example 3


```html
<input type="image" src="/test-assets/shared/search-icon.svg" title="Search" />
```
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is a title attribute considered accessible in this situation?

Co-Authored-By: Jean-Yves Moyen <jym@siteimprove.com>
Comment on lines 26 to +29
**Note:** `input` elements have a `type` attribute in the `Image button` state if it is set to any case-insensitive match of `image` (most of the time, using `<input type="image">`).

**Note:** The specification of the [`type`](https://html.spec.whatwg.org/#states-of-the-type-attribute) attribute describes in detail how to map the value of the attribute to its corresponding state.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If they are only required for understanding an example or two, they should probably be moved to the description of these examples. With the new applicability which has nothing to do with type or Image button, they look completely out of the place and it is not clear why a rule about buttons need this (for example, why precising how to put an input in the Image button state, but not precise how to put it in the Button, Reset Button or Submit Button state? And why even mention input elements on a rule about buttons?)

Comment on lines +211 to +234
#### Failed Example 5

This `input` element with 'type' attribute in the `Image button` state has an empty [accessible name][]. The `name` attribute can not be used to provide an [accessible name][].

```html
<input type="image" name="search" src="/test-assets/shared/search-icon.svg" />
```

#### Failed Example 6

This image button has an empty `alt` attribute, and no other attributes that can give it an [accessible name][].

```html
<input type="image" src="/test-assets/shared/search-icon.svg" alt="" />
```

#### Failed Example 7

This image button has an `aria-labelledby` attribute, but the referenced element does not exist. This gives the button an empty [accessible name][].

```html
<input type="image" src="/test-assets/shared/search-icon.svg" aria-labelledby="non-existing" />
```

Copy link
Collaborator

Choose a reason for hiding this comment

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

So, the description of "empty accessible name" is not correct. And these examples do not actually fail this rule (they fail the other rule given that the name is not descriptive).

The `button` element is tested separately from the `img` element. [Success Criterion 4.1.2 Name, Role, Value](https://www.w3.org/TR/WCAG21/#name-role-value) is applied to the button, whereas the image is tested under [Success Criterion 1.1.1 Non-text Content](https://www.w3.org/TR/WCAG21/#non-text-content)

```html
<button><img src="/test-assets/shared/search-icon.svg" alt="Search" /></button>
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not an image button as per the sense "input element in the Image Button state".
But this is the rule checking that elements with role of button have a (non empty) accessible name. In that case, there is an element with a role of button (the button element itself), thus the rule is applicable and passes because the button element gets its name from the content, here the, alt attribute of the image (iirc).

Comment on lines 103 to +121
#### Failed Example 1

The image button element has an empty [accessible name][]. The `name` attribute can not be used to provide an [accessible name][].
This `input` element with 'type' attribute in the `Image button` state has an empty [accessible name][], which cannot be descriptive. The `name` attribute does not provide an [accessible name][].

```html
<input type="image" name="search" src="/test-assets/shared/search-icon.svg" />
```

#### Failed Example 2

The image button has an empty `alt` attribute, and no other attributes that can give it an [accessible name][].
This image button has an `alt` attribute that is not descriptive as the [accessible name][].

```html
<input type="image" src="/test-assets/shared/search-icon.svg" alt="" />
<input type="image" src="/test-assets/shared/search-icon.svg" alt="Share" />
```

#### Failed Example 3

The image button has an `aria-labelledby` attribute, but the referenced element does not exist. This gives the button an empty [accessible name][].
The image button has an `aria-labelledby` attribute, but the referenced element does not exist. This gives the button an empty [accessible name][], which cannot be descriptive.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, but the description should say so rather than saying that it has an empty accessible name.

Comment on lines +147 to +155
This `button` element is separate from the `img` element.

```html
<button><img src="/test-assets/shared/search-icon.svg" alt="Search" /></button>
```

#### Inapplicable Example 4

The `img` element is not a user interface component, and so is not tested for [Success Criterion 4.1.2 Name, Role, Value](https://www.w3.org/TR/WCAG21/#name-role-value).
This `img` element is not button component.
Copy link
Collaborator

Choose a reason for hiding this comment

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

The rule is applicable to input elements in the Image Button state. So the reason that these snippets are inapplicable is the lack of such elements. It has nothing to do with button elements or components. To match the example description syntax, both these should be
"There is no input element in the Image Button state."
An extra sentence can be added. Maybe for Inapplicable Example 3 "A button element containing only an img element is not an Image Button, this rule specifically checks for input elements in the Image Button state". And for Inapplicable Example 4 "The img element alone is not an Image Button."

@EmmaJP
Copy link
Collaborator Author

EmmaJP commented Apr 9, 2020

Note - check if this has impact on image button has accessible name, which is a rule that has already been accepted by the task force and changes may need to be resubmitted. See #1120

@WilcoFiers
Copy link
Member

Closing due to inactivity.

@WilcoFiers WilcoFiers closed this Nov 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
reviewers wanted Rule Update Use this label for an existing rule that is being updated
Projects
None yet
Development

Successfully merging this pull request may close these issues.

One element relevant for multiple success criteria
3 participants