55 */
66
77import { getFocusableElements } from '@vaadin/a11y-base' ;
8- import { timeOut } from '@vaadin/component-base/src/async' ;
8+ import { timeOut } from '@vaadin/component-base/src/async.js ' ;
99import { Debouncer } from '@vaadin/component-base/src/debounce.js' ;
1010import { get } from '@vaadin/component-base/src/path-utils.js' ;
1111
@@ -147,8 +147,8 @@ export const SelectionMixin = (superClass) =>
147147 }
148148
149149 /** @private */
150- __clampIndex ( index ) {
151- return Math . max ( 0 , Math . min ( index , ( this . items || [ ] ) . length - 1 ) ) ;
150+ __updateFocusIndex ( index ) {
151+ this . __focusIndex = Math . max ( 0 , Math . min ( index , ( this . items || [ ] ) . length - 1 ) ) ;
152152 }
153153
154154 /** @private */
@@ -158,9 +158,9 @@ export const SelectionMixin = (superClass) =>
158158 }
159159
160160 const oldFocusIndex = this . __focusIndex ;
161- this . __focusIndex = this . __clampIndex ( this . __focusIndex ) ;
161+ this . __updateFocusIndex ( this . __focusIndex ) ;
162162 if ( oldFocusIndex !== this . __focusIndex ) {
163- this . __scheduleRequestContentUpdate ( ) ;
163+ this . __scheduleContentUpdate ( ) ;
164164 }
165165 // Items may have been emptied, need to update focusability
166166 this . __updateFocusable ( ) ;
@@ -173,7 +173,7 @@ export const SelectionMixin = (superClass) =>
173173
174174 /** @private */
175175 __selectionChanged ( ) {
176- this . __scheduleRequestContentUpdate ( ) ;
176+ this . __scheduleContentUpdate ( ) ;
177177 }
178178
179179 /** @private */
@@ -254,7 +254,7 @@ export const SelectionMixin = (superClass) =>
254254 }
255255
256256 /**
257- * Returns the rendered root element containing the given child element.
257+ * Returns the rendered root element matching or containing the given child element.
258258 * @private
259259 */
260260 __getRootElementByContent ( element ) {
@@ -275,7 +275,7 @@ export const SelectionMixin = (superClass) =>
275275 this . toggleAttribute ( 'interacting' , isInteracting ) ;
276276
277277 this . __updateFocusable ( ) ;
278- this . __scheduleRequestContentUpdate ( ) ;
278+ this . __scheduleContentUpdate ( ) ;
279279 }
280280
281281 /** @private */
@@ -322,7 +322,7 @@ export const SelectionMixin = (superClass) =>
322322
323323 /** @private */
324324 __onNavigationArrowKey ( down ) {
325- this . __focusIndex = this . __clampIndex ( this . __focusIndex + ( down ? 1 : - 1 ) ) ;
325+ this . __updateFocusIndex ( this . __focusIndex + ( down ? 1 : - 1 ) ) ;
326326 this . __focusElementWithFocusIndex ( ) ;
327327
328328 if ( this . __debounceRequestContentUpdate ) {
@@ -332,7 +332,7 @@ export const SelectionMixin = (superClass) =>
332332 }
333333
334334 /** @private */
335- __scheduleRequestContentUpdate ( ) {
335+ __scheduleContentUpdate ( ) {
336336 this . __debounceRequestContentUpdate = Debouncer . debounce (
337337 this . __debounceRequestContentUpdate ,
338338 timeOut . after ( 0 ) ,
@@ -370,7 +370,7 @@ export const SelectionMixin = (superClass) =>
370370 __onNavigationEnterKey ( ) {
371371 // Get the focused item
372372 const focusedItem = this . querySelector ( '[focused]' ) ;
373- // First the first focusable element in the focused item and focus it
373+ // Find the first focusable element in the item and focus it
374374 const focusableElement = getFocusableElements ( focusedItem ) . find ( ( el ) => el !== focusedItem ) ;
375375 if ( focusableElement ) {
376376 focusableElement . focus ( ) ;
@@ -409,7 +409,7 @@ export const SelectionMixin = (superClass) =>
409409 // Update focus index based on the focused item
410410 const rootElement = this . __getRootElementWithFocus ( ) ;
411411 if ( rootElement ) {
412- this . __focusIndex = rootElement . __index ;
412+ this . __updateFocusIndex ( rootElement . __index ) ;
413413 }
414414
415415 // Focus the root element matching focus index if focus came from outside
0 commit comments