Skip to content
This repository was archived by the owner on Sep 22, 2022. It is now read-only.

Commit e886aed

Browse files
committed
Add visible check
1 parent 0869b97 commit e886aed

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

index.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,18 @@ function keydown(event: KeyboardEvent): void {
3232
}
3333

3434
function focusable(el: Focusable): boolean {
35-
return el.tabIndex >= 0 && !el.disabled && !el.hidden && (!el.type || el.type !== 'hidden') && !el.closest('[hidden]')
35+
return (
36+
el.tabIndex >= 0 &&
37+
!el.disabled &&
38+
!el.hidden &&
39+
(!el.type || el.type !== 'hidden') &&
40+
!el.closest('[hidden]') &&
41+
visible(el)
42+
)
43+
}
44+
45+
function visible(el): boolean {
46+
return el.offsetWidth > 0 || el.offsetHeight > 0
3647
}
3748

3849
function restrictTabBehavior(event: KeyboardEvent): void {

0 commit comments

Comments
 (0)