@@ -38,13 +38,17 @@ export const KeyboardDirectionMixin = (superclass) =>
38
38
return false ;
39
39
}
40
40
41
- /** @protected */
42
- focus ( ) {
41
+ /**
42
+ * @param {FocusOptions= } options
43
+ * @protected
44
+ * @override
45
+ */
46
+ focus ( options ) {
43
47
const items = this . _getItems ( ) ;
44
48
if ( Array . isArray ( items ) ) {
45
49
const idx = this . _getAvailableIndex ( items , 0 , null , ( item ) => ! isElementHidden ( item ) ) ;
46
50
if ( idx >= 0 ) {
47
- this . _focus ( idx ) ;
51
+ this . _focus ( idx , options ) ;
48
52
}
49
53
}
50
54
}
@@ -114,7 +118,7 @@ export const KeyboardDirectionMixin = (superclass) =>
114
118
115
119
if ( idx >= 0 ) {
116
120
event . preventDefault ( ) ;
117
- this . _focus ( idx , true ) ;
121
+ this . _focus ( idx , { focusVisible : true } , true ) ;
118
122
}
119
123
}
120
124
@@ -150,30 +154,27 @@ export const KeyboardDirectionMixin = (superclass) =>
150
154
* Focus the item at given index. Override this method to add custom logic.
151
155
*
152
156
* @param {number } index
157
+ * @param {FocusOptions= } options
153
158
* @param {boolean } navigating
154
159
* @protected
155
160
*/
156
- _focus ( index , navigating = false ) {
161
+ _focus ( index , options , navigating = false ) {
157
162
const items = this . _getItems ( ) ;
158
163
159
- this . _focusItem ( items [ index ] , navigating ) ;
164
+ this . _focusItem ( items [ index ] , options , navigating ) ;
160
165
}
161
166
162
167
/**
163
168
* Focus the given item. Override this method to add custom logic.
164
169
*
165
170
* @param {Element } item
171
+ * @param {FocusOptions= } options
166
172
* @param {boolean } navigating
167
173
* @protected
168
174
*/
169
- _focusItem ( item ) {
175
+ _focusItem ( item , options ) {
170
176
if ( item ) {
171
- item . focus ( ) ;
172
-
173
- // Generally, the items are expected to implement `FocusMixin`
174
- // that would set this attribute based on the `keydown` event.
175
- // We set it manually to handle programmatic focus() calls.
176
- item . setAttribute ( 'focus-ring' , '' ) ;
177
+ item . focus ( options ) ;
177
178
}
178
179
}
179
180
0 commit comments