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): treat overflow:clip as hidden #3304

Merged
merged 2 commits into from
Nov 24, 2021
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
15 changes: 7 additions & 8 deletions lib/core/utils/get-scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @param {buffer} (Optional) allowed negligence in overflow
* @returns {Object | undefined}
*/
function getScroll(elm, buffer = 0) {
export default function getScroll(elm, buffer = 0) {
const overflowX = elm.scrollWidth > elm.clientWidth + buffer;
const overflowY = elm.scrollHeight > elm.clientHeight + buffer;

Expand All @@ -19,12 +19,8 @@ function getScroll(elm, buffer = 0) {
}

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

/**
* check direction of `overflow` and `scrollable`
Expand All @@ -38,4 +34,7 @@ function getScroll(elm, buffer = 0) {
}
}

export default getScroll;
function isScrollable(style, prop) {
const overflowProp = style.getPropertyValue(prop);
return ['scroll', 'auto'].includes(overflowProp);
}
12 changes: 12 additions & 0 deletions test/core/utils/get-scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ describe('axe.utils.getScroll', function() {
assert.isUndefined(actual);
});

it('returns undefined when element overflow is clip', function() {
var target = queryFixture(
'<div id="target" style="height: 200px; width: 200px; overflow: clip">' +
'<div style="height: 2000px; width: 100px; background-color: pink;">' +
'<p> Content </p>' +
'</div>' +
'</div>'
);
var actual = axe.utils.getScroll(target.actualNode);
assert.isUndefined(actual);
});

it('returns scroll offset when element overflow is auto', function() {
var target = queryFixture(
'<div id="target" style="height: 200px; width: 200px; overflow: auto">' +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,9 @@
</div>
</div>
</div>

<div id="inapplicable10" style="height: 200px; overflow-y: clip">
<div style="height: 2000px">
<p>Content</p>
</div>
</div>