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

color-contrast false positive on element styled as screen-reader-only #2962

Closed
dbjorge opened this issue May 25, 2021 · 5 comments · Fixed by #2985
Closed

color-contrast false positive on element styled as screen-reader-only #2962

dbjorge opened this issue May 25, 2021 · 5 comments · Fixed by #2985
Assignees
Labels
color contrast Color contrast issues fix Bug fixes pr A pr has been created for the issue rules Issue or false result from an axe-core rule

Comments

@dbjorge
Copy link
Contributor

dbjorge commented May 25, 2021

Product: axe-core

Expectation: Elements using the following sr-only CSS should be detected as inapplicable to the color-contrast rule:

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0px;
  border: 0px;
  overflow: hidden;
}

Gist containing a full self-contained repro

Actual: Elements with that sr-only styling can fail the color-contrast rule.

Motivation: An Accessibility Insights for Web user reported this as a false positive.

Notes:

As a workaround, we've recommended that the user add a clip: rect(0,0,0,0); property to their sr-only class, similar to Bootstrap's sr-only implementation. This causes axe-core to understand that the element should be ineligible for the color-contrast test.

However, the item is still invisible without the clip property (the combination of other properties is sufficient), so it would be ideal for axe-core to understand that.

This technically caused a false positive, but one that has a straightforward workaround and which is straightforward for a user to "fix" by adding noop color CSS according to the color-contrast instructions, so I'd consider this to be lower priority than most other false positive issues.


axe-core version: 4.2.1
axe-webdriver, extension or other integration version: Accessibility Insights for Web 2.26.1

Browser and Assistive Technology versions: Microsoft Edge Version 90.0.818.66 (Official build) (64-bit), no AT

For Tooling issues:
- Node version: n/a
- Platform:  n/a
@dbjorge
Copy link
Contributor Author

dbjorge commented May 25, 2021

(context: #2171 discusses a similar symptom with a different root cause)

@WilcoFiers
Copy link
Contributor

I thought axe-core did exclude these... I'll have to take a closer look. Thank you for reporting Dan!

@WilcoFiers WilcoFiers added color contrast Color contrast issues fix Bug fixes rules Issue or false result from an axe-core rule labels May 29, 2021
@straker
Copy link
Contributor

straker commented Jun 1, 2021

I believe our sr-only exclusion was based on a few things:

  • clipPath
  • width/height set to 0
  • moves text offscreen

Our code is saying this version of sr-only is visible since it doesn't do any of those things. I'm not sure what would be the best approach to say that this element is hidden (width/height set to 1 maybe?).

@WilcoFiers
Copy link
Contributor

Still needs to go to QA.

@straker straker added the pr A pr has been created for the issue label Jun 15, 2021
@padmavemulapati
Copy link

Verified with the latest develop branch axe-core code base, test snippet
have an element with failing color contrast colors and add that sr-only class no longer fails

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
color contrast Color contrast issues fix Bug fixes pr A pr has been created for the issue rules Issue or false result from an axe-core rule
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants