Skip to content

Commit 9be00a9

Browse files
flurmbodiasbruno
authored andcommittedOct 4, 2019
[fixed] some untabbable elements are being returned from findTabbable (#774)
* [fixed] some untabbable elements are being returned from findTabbable - add test - fix apparent typo in test spec
1 parent 4dd25ac commit 9be00a9

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed
 

‎specs/Modal.helpers.spec.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,21 @@ export default () => {
9999

100100
it("includes inputs visible because of overflow == visible", () => {
101101
const input = document.createElement("input");
102-
elem.style.width = "0";
103-
elem.style.height = "0";
104-
elem.style.overflow = "visible";
102+
input.style.width = "0";
103+
input.style.height = "0";
104+
input.style.overflow = "visible";
105105
elem.appendChild(input);
106106
tabbable(elem).should.containEql(input);
107107
});
108+
109+
it("excludes elements with overflow == visible if there is no visible content", () => {
110+
const button = document.createElement("button");
111+
button.innerHTML = "You can't see me!";
112+
button.style.display = "none";
113+
button.style.overflow = "visible";
114+
elem.appendChild(button);
115+
tabbable(elem).should.not.containEql(button);
116+
});
108117
});
109118
});
110119
};

‎src/helpers/tabbable.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ function hidesContents(element) {
2121
// Otherwise we need to check some styles
2222
const style = window.getComputedStyle(element);
2323
return zeroSize
24-
? style.getPropertyValue("overflow") !== "visible"
24+
? style.getPropertyValue("overflow") !== "visible" ||
25+
// if 'overflow: visible' set, check if there is actually any overflow
26+
(element.scrollWidth <= 0 && element.scrollHeight <= 0)
2527
: style.getPropertyValue("display") == "none";
2628
}
2729

0 commit comments

Comments
 (0)