@@ -137,6 +137,7 @@ export class TabListPattern {
137
137
/** The id of the current active tab. */
138
138
activedescendant = computed ( ( ) => this . focusManager . getActiveDescendant ( ) ) ;
139
139
140
+ /** Whether selection should follow focus. */
140
141
followFocus = computed ( ( ) => this . inputs . selectionMode ( ) === 'follow' ) ;
141
142
142
143
/** The key used to navigate to the previous tab in the tablist. */
@@ -157,33 +158,20 @@ export class TabListPattern {
157
158
158
159
/** The keydown event manager for the tablist. */
159
160
keydown = computed ( ( ) => {
160
- const manager = new KeyboardEventManager ( ) ;
161
-
162
- if ( this . followFocus ( ) ) {
163
- manager
164
- . on ( this . prevKey , ( ) => this . prev ( { selectOne : true } ) )
165
- . on ( this . nextKey , ( ) => this . next ( { selectOne : true } ) )
166
- . on ( 'Home' , ( ) => this . first ( { selectOne : true } ) )
167
- . on ( 'End' , ( ) => this . last ( { selectOne : true } ) ) ;
168
- } else {
169
- manager
170
- . on ( this . prevKey , ( ) => this . prev ( ) )
171
- . on ( this . nextKey , ( ) => this . next ( ) )
172
- . on ( 'Home' , ( ) => this . first ( ) )
173
- . on ( 'End' , ( ) => this . last ( ) )
174
- . on ( ' ' , ( ) => this . _updateSelection ( { selectOne : true } ) )
175
- . on ( 'Enter' , ( ) => this . _updateSelection ( { selectOne : true } ) ) ;
176
- }
161
+ const manager = new KeyboardEventManager ( )
162
+ . on ( this . prevKey , ( ) => this . prev ( { selectOne : this . followFocus ( ) } ) )
163
+ . on ( this . nextKey , ( ) => this . next ( { selectOne : this . followFocus ( ) } ) )
164
+ . on ( 'Home' , ( ) => this . first ( { selectOne : this . followFocus ( ) } ) )
165
+ . on ( 'End' , ( ) => this . last ( { selectOne : this . followFocus ( ) } ) )
166
+ . on ( ' ' , ( ) => this . selection . selectOne ( ) )
167
+ . on ( 'Enter' , ( ) => this . selection . selectOne ( ) ) ;
177
168
178
169
return manager ;
179
170
} ) ;
180
171
181
172
/** The pointerdown event manager for the tablist. */
182
173
pointerdown = computed ( ( ) => {
183
- const manager = new PointerEventManager ( ) ;
184
- manager . on ( e => this . goto ( e , { selectOne : true } ) ) ;
185
-
186
- return manager ;
174
+ return new PointerEventManager ( ) . on ( e => this . goto ( e , { selectOne : true } ) ) ;
187
175
} ) ;
188
176
189
177
constructor ( readonly inputs : TabListInputs ) {
0 commit comments