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(scrollable-region-focusable): exclude overflow:hidden as not scrollable #1599

Merged
merged 2 commits into from
May 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/core/utils/get-scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ axe.utils.getScroll = function getScroll(elm, buffer = 0) {
}

const style = window.getComputedStyle(elm);
const scrollableX = style.getPropertyValue('overflow-x') !== 'visible';
const scrollableY = style.getPropertyValue('overflow-y') !== 'visible';
const overflowXStyle = style.getPropertyValue('overflow-x');
const overflowYStyle = style.getPropertyValue('overflow-y');
const scrollableX =
overflowXStyle !== 'visible' && overflowXStyle !== 'hidden';
const scrollableY =
overflowYStyle !== 'visible' && overflowYStyle !== 'hidden';

/**
* check direction of `overflow` and `scrollable`
Expand Down
5 changes: 1 addition & 4 deletions test/core/utils/get-scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ describe('axe.utils.getScroll', function() {
'</div>'
);
var actual = axe.utils.getScroll(target.actualNode);
assert.isDefined(actual);
assert.hasAllKeys(actual, ['elm', 'top', 'left']);
assert.equal(actual.top, 0);
assert.equal(actual.left, 0);
assert.isUndefined(actual);
});

it('returns scroll offset when element overflow is auto', function() {
Expand Down
2 changes: 1 addition & 1 deletion test/core/utils/scroll-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('axe.utils.getScrollState', function() {
fixture.innerHTML =
'<div style="overflow:auto; height: 50px" id="tgt1">' +
'<div style="height: 100px"> Han Solo </div>' +
'<div style="overflow: hidden; height: 50px" id="tgt2">' +
'<div style="overflow: auto; height: 50px" id="tgt2">' +
'<div style="height: 100px"> Chewbacca </div>' +
'</div>' +
'</div>';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<!-- pass -->
<div id="pass1" style="overflow: hidden; height: 5px;">
<div id="pass1" style="overflow-y: scroll; height: 5px;">
<input type="text" />
</div>

<div id="pass2" style="height: 200px; overflow: hidden" tabindex="0">
<div id="pass2" style="height: 200px; overflow-y: auto" tabindex="0">
<div style="height: 2000px">
<p>Content</p>
</div>
Expand All @@ -17,17 +17,11 @@
</div>

<!-- fail -->
<div id="fail1" style="height: 200px; width: 200px; overflow: hidden">
<div style="height: 2000px; width: 100px;">
<p>Content</p>
</div>
</div>

<div id="fail2" style="height: 5px; overflow: auto;">
<div id="fail1" style="height: 5px; overflow: auto;">
<input type="text" tabindex="-1" />
</div>

<div id="fail3" style="height: 5px; overflow: auto;">
<div id="fail2" style="height: 5px; overflow: auto;">
<input type="text" tabindex="-1" />
<select tabindex="-1"></select>
<textarea tabindex="-1"></textarea>
Expand Down Expand Up @@ -68,3 +62,9 @@
<p>Content</p>
</div>
</div>

<div id="inapplicable6" style="height: 200px; width: 200px; overflow: hidden">
<div style="height: 2000px; width: 100px;">
<p>Content</p>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"description": "scrollable-region-focusable tests",
"rule": "scrollable-region-focusable",
"violations": [["#fail1"], ["#fail2"], ["#fail3"]],
"violations": [["#fail1"], ["#fail2"]],
"passes": [["#pass1"], ["#pass2"], ["#pass3"]]
}
4 changes: 2 additions & 2 deletions test/rule-matches/scrollable-region-focusable-matches.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('scrollable-region-focusable-matches', function() {
assert.isFalse(actual);
});

it('returns true when element is scrollable (overflow=hidden)', function() {
it('returns false when element is not scrollable (overflow=hidden)', function() {
var target = queryFixture(
'<div id="target" style="height: 200px; width: 200px; overflow: hidden">' +
'<div style="height: 2000px; width: 100px; background-color: pink;">' +
Expand All @@ -51,7 +51,7 @@ describe('scrollable-region-focusable-matches', function() {
'</div>'
);
var actual = rule.matches(target.actualNode, target);
assert.isTrue(actual);
assert.isFalse(actual);
});

it('returns true when element is scrollable (overflow=auto)', function() {
Expand Down