@@ -130,6 +130,7 @@ const BaseList = (superClass) => class extends superClass {
130130 }
131131
132132 const items = this . _getSelectableItems ( ) ;
133+ items . forEach ( ( item , i ) => this . setIndex ( item , i === 0 ? 0 : - 1 ) ) ;
133134 items [ 0 ] . focus ( ) ;
134135 }
135136
@@ -140,6 +141,9 @@ const BaseList = (superClass) => class extends superClass {
140141 }
141142
142143 const items = this . _getSelectableItems ( ) ;
144+ items . forEach ( ( item , i ) =>
145+ this . setIndex ( item , i === items . length - 1 ? 0 : - 1 )
146+ ) ;
143147 items [ items . length - 1 ] . focus ( ) ;
144148 }
145149
@@ -159,8 +163,11 @@ const BaseList = (superClass) => class extends superClass {
159163 }
160164
161165 if ( index < items . length - 1 ) {
166+ this . setIndex ( target , - 1 ) ;
167+ this . setIndex ( items [ index + 1 ] , 0 ) ;
162168 items [ index + 1 ] . focus ( ) ;
163169 } else {
170+ items . forEach ( ( item , i ) => this . setIndex ( item , i === 0 ? 0 : - 1 ) ) ;
164171 items [ 0 ] . focus ( ) ;
165172 }
166173 }
@@ -181,8 +188,13 @@ const BaseList = (superClass) => class extends superClass {
181188 }
182189
183190 if ( index > 0 ) {
191+ this . setIndex ( target , - 1 ) ;
192+ this . setIndex ( items [ index - 1 ] , 0 ) ;
184193 items [ index - 1 ] . focus ( ) ;
185194 } else {
195+ items . forEach ( ( item , i ) =>
196+ this . setIndex ( item , i === items [ length - 1 ] ? 0 : - 1 )
197+ ) ;
186198 items [ items . length - 1 ] . focus ( ) ;
187199 }
188200 }
@@ -203,6 +215,12 @@ const BaseList = (superClass) => class extends superClass {
203215 }
204216 }
205217
218+ setIndex ( element , value ) {
219+ if ( element instanceof HTMLElement ) {
220+ element . setAttribute ( "tabindex" , value ) ;
221+ }
222+ }
223+
206224 /**
207225 Returns {@link BaseList} interaction options.
208226
0 commit comments