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): inconsistency of bgOverlap message based on scroll #3310

Merged
merged 3 commits into from
Nov 29, 2021

Conversation

WilcoFiers
Copy link
Contributor

bgOverlap was not computed correctly. What it was doing is use elementsFromPoint on the top-right pixel of a field. It got the tests to pass, but doing that doesn't actually tell us the difference between an element that overlaps, and a non-text element that simply sits inline with the text of an element. Because axe-core no longer scrolls the page when running color-contrast, our use of elementsFromPoint caused inconsistencies.

The fix here is to check if an element that appears visually on top of the element with text is actually an inline descendant of it. That gets rid of elementsFromPoint, solving the inconsistency problem, and it means we can actually properly tell what elements might overlap, and which ones are in the same flow as the text.

Closes issue: #3309

@WilcoFiers WilcoFiers requested a review from a team as a code owner November 24, 2021 12:08
@@ -1046,7 +1080,7 @@ describe('color.getBackgroundColor', function() {

it('returns the html background when body does not cover the element', function() {
fixture.innerHTML =
'<div id="target" style="position: absolute; top: 1000px;"><label>elm<input></label></div>';
'<div id="target" style="position: absolute; top: 1000px;">elm<input></div>';
Copy link
Contributor Author

@WilcoFiers WilcoFiers Nov 24, 2021

Choose a reason for hiding this comment

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

Rule would never target the parent of en element with text.

}
// Ignore inline descendants, for example:
// <p>text <img></p>; We don't care about the <img> element,
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if <img> is positioned somehow, acting like a background?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

position: absolute / sticky force an element into display:block. I'll put in a test for it though.

@WilcoFiers WilcoFiers merged commit 25eff98 into develop Nov 29, 2021
@WilcoFiers WilcoFiers deleted the content-overlapping-fix branch November 29, 2021 16:11
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