5
5
*/
6
6
7
7
import { getFocusableElements } from '@vaadin/a11y-base' ;
8
- import { timeOut } from '@vaadin/component-base/src/async' ;
8
+ import { timeOut } from '@vaadin/component-base/src/async.js ' ;
9
9
import { Debouncer } from '@vaadin/component-base/src/debounce.js' ;
10
10
import { get } from '@vaadin/component-base/src/path-utils.js' ;
11
11
@@ -147,8 +147,8 @@ export const SelectionMixin = (superClass) =>
147
147
}
148
148
149
149
/** @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 ) ) ;
152
152
}
153
153
154
154
/** @private */
@@ -158,9 +158,9 @@ export const SelectionMixin = (superClass) =>
158
158
}
159
159
160
160
const oldFocusIndex = this . __focusIndex ;
161
- this . __focusIndex = this . __clampIndex ( this . __focusIndex ) ;
161
+ this . __updateFocusIndex ( this . __focusIndex ) ;
162
162
if ( oldFocusIndex !== this . __focusIndex ) {
163
- this . __scheduleRequestContentUpdate ( ) ;
163
+ this . __scheduleContentUpdate ( ) ;
164
164
}
165
165
// Items may have been emptied, need to update focusability
166
166
this . __updateFocusable ( ) ;
@@ -173,7 +173,7 @@ export const SelectionMixin = (superClass) =>
173
173
174
174
/** @private */
175
175
__selectionChanged ( ) {
176
- this . __scheduleRequestContentUpdate ( ) ;
176
+ this . __scheduleContentUpdate ( ) ;
177
177
}
178
178
179
179
/** @private */
@@ -254,7 +254,7 @@ export const SelectionMixin = (superClass) =>
254
254
}
255
255
256
256
/**
257
- * Returns the rendered root element containing the given child element.
257
+ * Returns the rendered root element matching or containing the given child element.
258
258
* @private
259
259
*/
260
260
__getRootElementByContent ( element ) {
@@ -275,7 +275,7 @@ export const SelectionMixin = (superClass) =>
275
275
this . toggleAttribute ( 'interacting' , isInteracting ) ;
276
276
277
277
this . __updateFocusable ( ) ;
278
- this . __scheduleRequestContentUpdate ( ) ;
278
+ this . __scheduleContentUpdate ( ) ;
279
279
}
280
280
281
281
/** @private */
@@ -322,7 +322,7 @@ export const SelectionMixin = (superClass) =>
322
322
323
323
/** @private */
324
324
__onNavigationArrowKey ( down ) {
325
- this . __focusIndex = this . __clampIndex ( this . __focusIndex + ( down ? 1 : - 1 ) ) ;
325
+ this . __updateFocusIndex ( this . __focusIndex + ( down ? 1 : - 1 ) ) ;
326
326
this . __focusElementWithFocusIndex ( ) ;
327
327
328
328
if ( this . __debounceRequestContentUpdate ) {
@@ -332,7 +332,7 @@ export const SelectionMixin = (superClass) =>
332
332
}
333
333
334
334
/** @private */
335
- __scheduleRequestContentUpdate ( ) {
335
+ __scheduleContentUpdate ( ) {
336
336
this . __debounceRequestContentUpdate = Debouncer . debounce (
337
337
this . __debounceRequestContentUpdate ,
338
338
timeOut . after ( 0 ) ,
@@ -370,7 +370,7 @@ export const SelectionMixin = (superClass) =>
370
370
__onNavigationEnterKey ( ) {
371
371
// Get the focused item
372
372
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
374
374
const focusableElement = getFocusableElements ( focusedItem ) . find ( ( el ) => el !== focusedItem ) ;
375
375
if ( focusableElement ) {
376
376
focusableElement . focus ( ) ;
@@ -409,7 +409,7 @@ export const SelectionMixin = (superClass) =>
409
409
// Update focus index based on the focused item
410
410
const rootElement = this . __getRootElementWithFocus ( ) ;
411
411
if ( rootElement ) {
412
- this . __focusIndex = rootElement . __index ;
412
+ this . __updateFocusIndex ( rootElement . __index ) ;
413
413
}
414
414
415
415
// Focus the root element matching focus index if focus came from outside
0 commit comments