@@ -137,6 +137,7 @@ export class TabListPattern {
137137 /** The id of the current active tab. */
138138 activedescendant = computed ( ( ) => this . focusManager . getActiveDescendant ( ) ) ;
139139
140+ /** Whether selection should follow focus. */
140141 followFocus = computed ( ( ) => this . inputs . selectionMode ( ) === 'follow' ) ;
141142
142143 /** The key used to navigate to the previous tab in the tablist. */
@@ -157,33 +158,20 @@ export class TabListPattern {
157158
158159 /** The keydown event manager for the tablist. */
159160 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 ( ) ) ;
177168
178169 return manager ;
179170 } ) ;
180171
181172 /** The pointerdown event manager for the tablist. */
182173 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 } ) ) ;
187175 } ) ;
188176
189177 constructor ( readonly inputs : TabListInputs ) {
0 commit comments