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

fix(color-contrast): ignore aria-disabled labels #2130

Merged
merged 10 commits into from
Jul 16, 2020

Conversation

WilcoFiers
Copy link
Contributor

@WilcoFiers WilcoFiers commented Mar 25, 2020

If an element is a descendent of an aria-labelledby reference, and any of the elements referencing it has disabled, the label must be ignored by the color-contrast rule.

Closes issue: #2090

Reviewer checks

Required fields, to be filled out by PR reviewer(s)

  • Follows the commit message policy, appropriate for next version
  • Code is reviewed for security

If an element is a descendent of an aria-labelledby reference, and any
of the elements referencing it has disabled, the label must be
ignored by the color-contrast rule.
@WilcoFiers WilcoFiers requested a review from a team as a code owner March 25, 2020 12:41
return false;
const ariaLabelledbyControls = [];
let ancestorNode = virtualNode;
while (ancestorNode) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is going to very slow on large pages as it will check the entire parent tree for every node (include subnodes of nodes already checked). The result of this gathering should be cached on each of the nodes checked so the next subnode only has to look up 1 level to find the answer.

See https://github.com/dequelabs/axe-core/blob/develop/lib/core/utils/is-hidden.js for a similar approach.

test/commons/forms/is-disabled.js Outdated Show resolved Hide resolved
test/commons/forms/is-disabled.js Outdated Show resolved Hide resolved
test/rule-matches/color-contrast-matches.js Outdated Show resolved Hide resolved
test/rule-matches/color-contrast-matches.js Outdated Show resolved Hide resolved
test/rule-matches/color-contrast-matches.js Outdated Show resolved Hide resolved
@straker
Copy link
Contributor

straker commented Mar 26, 2020

Also, we just merged a PR that updated the entire commons.forms to ES Modules. We'll probably need to update the new forms.isDisabled function to ES Modules before we merge this as well.

@WilcoFiers WilcoFiers requested a review from straker July 6, 2020 09:56
@WilcoFiers WilcoFiers dismissed straker’s stale review July 6, 2020 09:56

Please check again

straker
straker previously requested changes Jul 6, 2020
lib/commons/forms/is-disabled.js Outdated Show resolved Hide resolved
candidate = querySelectorAll(
relevantVirtualNode,
// implicit label of disabled control
const query =
Copy link
Contributor

Choose a reason for hiding this comment

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

If we have an explicit control, do we need to check for an implicit one as well if the explicit control is not disabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so. If an elm has an explicit label, the implicit one will not be applied.

Copy link
Contributor

@straker straker Jul 8, 2020

Choose a reason for hiding this comment

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

The way this if statement above is written, if the element has an explicit label and it's not disabled, it will continue to look at the implicit label. Based on your answer we would get into a state where if the explicit label is not disable but the implicit one is, we would ignore the element even though the implicit label should not apply.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thought about this, I think fixing this is well outside of the scope of this PR. I'll open an issue for it instead.

test/rule-matches/color-contrast-matches.js Outdated Show resolved Hide resolved
WilcoFiers and others added 2 commits July 7, 2020 14:01
Co-authored-by: Steven Lambert <2433219+straker@users.noreply.github.com>
Copy link
Contributor

@straker straker left a comment

Choose a reason for hiding this comment

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

The if statement will allow a disabled implicit label to override the non-disabled explicit label.

@WilcoFiers WilcoFiers merged commit e451b87 into develop Jul 16, 2020
@WilcoFiers WilcoFiers deleted the aria-labelled-disabled-control-contrast branch July 16, 2020 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants