File tree Expand file tree Collapse file tree 1 file changed +14
-11
lines changed
src/aria/private/behaviors/list-typeahead Expand file tree Collapse file tree 1 file changed +14
-11
lines changed Original file line number Diff line number Diff line change @@ -83,19 +83,22 @@ export class ListTypeahead<T extends ListTypeaheadItem> {
8383 * current query starting from the the current anchor index.
8484 */
8585 private _getItem ( ) {
86- let items = this . focusManager . inputs . items ( ) ;
87- const after = items . slice ( this . _startIndex ( ) ! + 1 ) ;
88- const before = items . slice ( 0 , this . _startIndex ( ) ! ) ;
89- items = after . concat ( before ) ;
90- items . push ( this . inputs . items ( ) [ this . _startIndex ( ) ! ] ) ;
91-
92- const focusableItems = [ ] ;
93- for ( const item of items ) {
94- if ( this . focusManager . isFocusable ( item ) ) {
95- focusableItems . push ( item ) ;
86+ const items = this . focusManager . inputs . items ( ) ;
87+ const itemCount = items . length ;
88+ const startIndex = this . _startIndex ( ) ! ;
89+
90+ for ( let i = 0 ; i < itemCount ; i ++ ) {
91+ const index = ( startIndex + 1 + i ) % itemCount ;
92+ const item = items [ index ] ;
93+
94+ if (
95+ this . focusManager . isFocusable ( item ) &&
96+ item . searchTerm ( ) . toLowerCase ( ) . startsWith ( this . _query ( ) )
97+ ) {
98+ return item ;
9699 }
97100 }
98101
99- return focusableItems . find ( i => i . searchTerm ( ) . toLowerCase ( ) . startsWith ( this . _query ( ) ) ) ;
102+ return undefined ;
100103 }
101104}
You can’t perform that action at this time.
0 commit comments