Skip to content

Commit aca5261

Browse files
galexandradediasbruno
authored andcommitted
fixing element with display 'contents' is visible and is tabbable
1 parent df0665e commit aca5261

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

src/helpers/tabbable.js

+18-7
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,19 @@
1010
* http://api.jqueryui.com/category/ui-core/
1111
*/
1212

13+
const DISPLAY_NONE = "none";
14+
const DISPLAY_CONTENTS = "contents";
15+
1316
const tabbableNode = /input|select|textarea|button|object|iframe/;
1417

18+
function isNotOverflowing(element, style) {
19+
return (
20+
style.getPropertyValue("overflow") !== "visible" ||
21+
// if 'overflow: visible' set, check if there is actually any overflow
22+
(element.scrollWidth <= 0 && element.scrollHeight <= 0)
23+
);
24+
}
25+
1526
function hidesContents(element) {
1627
const zeroSize = element.offsetWidth <= 0 && element.offsetHeight <= 0;
1728

@@ -21,11 +32,10 @@ function hidesContents(element) {
2132
try {
2233
// Otherwise we need to check some styles
2334
const style = window.getComputedStyle(element);
35+
const displayValue = style.getPropertyValue("display");
2436
return zeroSize
25-
? style.getPropertyValue("overflow") !== "visible" ||
26-
// if 'overflow: visible' set, check if there is actually any overflow
27-
(element.scrollWidth <= 0 && element.scrollHeight <= 0)
28-
: style.getPropertyValue("display") == "none";
37+
? displayValue !== DISPLAY_CONTENTS && isNotOverflowing(element, style)
38+
: displayValue === DISPLAY_NONE;
2939
} catch (exception) {
3040
// eslint-disable-next-line no-console
3141
console.warn("Failed to inspect element style");
@@ -68,9 +78,10 @@ export default function findTabbableDescendants(element) {
6878
const descendants = [].slice
6979
.call(element.querySelectorAll("*"), 0)
7080
.reduce(
71-
(finished, el) => finished.concat(
72-
!el.shadowRoot ? [el] : findTabbableDescendants(el.shadowRoot)
73-
),
81+
(finished, el) =>
82+
finished.concat(
83+
!el.shadowRoot ? [el] : findTabbableDescendants(el.shadowRoot)
84+
),
7485
[]
7586
);
7687
return descendants.filter(tabbable);

0 commit comments

Comments
 (0)