fix(color-contrast): inconsistency of bgOverlap message based on scroll#3310
Merged
WilcoFiers merged 3 commits intodevelopfrom Nov 29, 2021
Merged
fix(color-contrast): inconsistency of bgOverlap message based on scroll#3310WilcoFiers merged 3 commits intodevelopfrom
WilcoFiers merged 3 commits intodevelopfrom
Conversation
46c2d24 to
3f0fd31
Compare
WilcoFiers
commented
Nov 24, 2021
| 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>'; |
Contributor
Author
There was a problem hiding this comment.
Rule would never target the parent of en element with text.
dylanb
reviewed
Nov 24, 2021
| return true; | ||
| } | ||
| // Ignore inline descendants, for example: | ||
| // <p>text <img></p>; We don't care about the <img> element, |
Contributor
There was a problem hiding this comment.
What happens if <img> is positioned somehow, acting like a background?
Contributor
Author
There was a problem hiding this comment.
position: absolute / sticky force an element into display:block. I'll put in a test for it though.
dylanb
approved these changes
Nov 29, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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