question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incomplete color-contrast check

See original GitHub issue

Reference: #1539 and #1185.

We are observing a flaky color-contrast check that gets triggered due to viewport size changes. Initially we were using v3.1.2, and got the error in #1185.

I have now created a reproduction case with v3.3.1, see https://html-is.glitch.me/axe-core-color-contrast.html. In Chrome, these are the results I am getting:

When viewport width is 800px, 1 incomplete check is reported.

When viewport width is 850px, 1 violation and 1 incomplete color-contrast check are reported.

When viewport width is < 760px or > 900px, 1 color-contrast violation is reported.

The expected result is there should always be 1 color-contrast violation reported on this page.

I tried to debug this, and it comes down to the scrollIntoView call.

When axe-core calls scrollIntoView on the sidebar <span> element at 800px & 850px, nothing happens, because the element is partially visible already. This breaks the check because the element contains a child element which is outside the viewport. Changing the scrollIntoView call to (https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView):

elm.scrollIntoView({block: alignToTop ? 'start' : 'end', inline: 'end'});

fixes the issue, as it will ensure that the element is always scrolled fully into view if possible.

I’m not sure what browser compatibility is required of this check for axe-core, and in Safari I actually consistently get Element's background color could not be determined because it partially overlaps other elements regardless of viewport size. So the fix would definitely require a deeper look.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
haonliucommented, Sep 27, 2019

we’ve experienced the same issue and tried the fix suggested by @muan and it works!

1reaction
strakercommented, Aug 3, 2019

So it looks like there’s two different problems. The first is as you identified in that we need to scroll the element fully into view before we check for it (including horizontal scrolling). The second seems to be that Safari does not add the span parent tag of the button from the elementsFromPoint API, thus making it seem like there’s a span overlapping the button in our checks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Text elements must have sufficient color contrast against the ...
Note: Elements found to have a 1:1 ratio are considered "incomplete" and require a manual review. Use the color contrast analyzer below to...
Read more >
WCAG 2.1 Color Contrast Checker - ADA Site Compliance
Our Compliance Contrast Checker helps determine the accessibility of text size, color contrast, and spot checks your visual elements. People who are color...
Read more >
2.5 Testing PDF Color Contrast for Accessibility - YouTube
... discussed in this videohttps://www.tceq.texas.gov/downloads/agency/accessibility/tutorials/2-5-testing-pdf- color-contrast • V...
Read more >
Contrast Checker - WebAIM
Use our link contrast checker to evaluate links that are identified using color alone. New! This tool also functions as a basic API....
Read more >
Color Contrast And Why You Should Rethink It
Let's use the Colour Contrast Checker to test medium-gray text ( 102 102 102 in RGB and #666666 in hexadecimal) and light-gray text...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found