File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -85,13 +85,17 @@ function fireCommitEvent(target: Element): void {
85
85
)
86
86
}
87
87
88
+ function visible ( el ) : boolean {
89
+ return ! el . hidden && ( ! el . type || el . type !== 'hidden' ) && ( el . offsetWidth > 0 || el . offsetHeight > 0 )
90
+ }
91
+
88
92
export function navigate (
89
93
input : HTMLTextAreaElement | HTMLInputElement ,
90
94
list : HTMLElement ,
91
95
indexDiff : - 1 | 1 = 1
92
96
) : void {
93
- const focusEl = list . querySelector ( '[aria-selected="true"]:not([hidden])' )
94
- const els = Array . from ( list . querySelectorAll ( '[role="option"]:not([hidden])' ) )
97
+ const focusEl = Array . from ( list . querySelectorAll ( '[aria-selected="true"]' ) ) . filter ( visible ) [ 0 ]
98
+ const els = Array . from ( list . querySelectorAll ( '[role="option"]' ) ) . filter ( visible )
95
99
const focusIndex = els . indexOf ( focusEl )
96
100
let indexOfItem = indexDiff === 1 ? 0 : els . length - 1
97
101
if ( focusEl && focusIndex >= 0 ) {
You can’t perform that action at this time.
0 commit comments