@@ -91,6 +91,9 @@ export class ListboxPattern<V> {
91
91
return this . inputs . textDirection ( ) === 'rtl' ? 'ArrowLeft' : 'ArrowRight' ;
92
92
} ) ;
93
93
94
+ /** Represents the space key. Does nothing when the user is actively using typeahead. */
95
+ spaceKey = computed ( ( ) => ( this . typeahead . query ( ) . length ? '' : ' ' ) ) ;
96
+
94
97
/** The regexp used to decide if a key should trigger typeahead. */
95
98
typeaheadRegexp = / ^ .$ / ; // TODO: Ignore spaces?
96
99
@@ -127,7 +130,7 @@ export class ListboxPattern<V> {
127
130
128
131
if ( this . inputs . multi ( ) ) {
129
132
manager
130
- . on ( Modifier . Shift , ' ' , ( ) => this . _updateSelection ( { selectFromAnchor : true } ) )
133
+ . on ( Modifier . Shift , this . spaceKey , ( ) => this . _updateSelection ( { selectFromAnchor : true } ) )
131
134
. on ( Modifier . Shift , 'Enter' , ( ) => this . _updateSelection ( { selectFromAnchor : true } ) )
132
135
. on ( Modifier . Shift , this . prevKey , ( ) => this . prev ( { toggle : true } ) )
133
136
. on ( Modifier . Shift , this . nextKey , ( ) => this . next ( { toggle : true } ) )
@@ -137,12 +140,12 @@ export class ListboxPattern<V> {
137
140
}
138
141
139
142
if ( ! this . followFocus ( ) && this . inputs . multi ( ) ) {
140
- manager . on ( ' ' , ( ) => this . _updateSelection ( { toggle : true } ) ) ;
143
+ manager . on ( this . spaceKey , ( ) => this . _updateSelection ( { toggle : true } ) ) ;
141
144
manager . on ( 'Enter' , ( ) => this . _updateSelection ( { toggle : true } ) ) ;
142
145
}
143
146
144
147
if ( ! this . followFocus ( ) && ! this . inputs . multi ( ) ) {
145
- manager . on ( ' ' , ( ) => this . _updateSelection ( { toggleOne : true } ) ) ;
148
+ manager . on ( this . spaceKey , ( ) => this . _updateSelection ( { toggleOne : true } ) ) ;
146
149
manager . on ( 'Enter' , ( ) => this . _updateSelection ( { toggleOne : true } ) ) ;
147
150
}
148
151
0 commit comments