@@ -16,7 +16,7 @@ import {
16
16
QueryList
17
17
} from '@angular/core' ;
18
18
import { ActiveDescendantKeyManager , Highlightable , ListKeyManagerOption } from '@angular/cdk/a11y' ;
19
- import { END , ENTER , HOME , SPACE } from '@angular/cdk/keycodes' ;
19
+ import { DOWN_ARROW , END , ENTER , HOME , SPACE , UP_ARROW } from '@angular/cdk/keycodes' ;
20
20
import { BooleanInput , coerceBooleanProperty } from '@angular/cdk/coercion' ;
21
21
import { SelectionChange , SelectionModel } from '@angular/cdk/collections' ;
22
22
import { defer , merge , Observable , Subject } from 'rxjs' ;
@@ -259,7 +259,10 @@ export class CdkListbox implements AfterContentInit, OnDestroy, OnInit {
259
259
260
260
private _initKeyManager ( ) {
261
261
this . _listKeyManager = new ActiveDescendantKeyManager ( this . _options )
262
- . withWrap ( ) . withVerticalOrientation ( ) . withTypeAhead ( ) ;
262
+ . withWrap ( )
263
+ . withVerticalOrientation ( )
264
+ . withTypeAhead ( )
265
+ . withAllowedModifierKeys ( [ 'shiftKey' ] ) ;
263
266
264
267
this . _listKeyManager . change . pipe ( takeUntil ( this . _destroyed ) ) . subscribe ( ( ) => {
265
268
this . _updateActiveOption ( ) ;
@@ -287,6 +290,7 @@ export class CdkListbox implements AfterContentInit, OnDestroy, OnInit {
287
290
288
291
const manager = this . _listKeyManager ;
289
292
const { keyCode} = event ;
293
+ const previousActiveIndex = manager . activeItemIndex ;
290
294
291
295
if ( keyCode === HOME || keyCode === END ) {
292
296
event . preventDefault ( ) ;
@@ -300,6 +304,12 @@ export class CdkListbox implements AfterContentInit, OnDestroy, OnInit {
300
304
} else {
301
305
manager . onKeydown ( event ) ;
302
306
}
307
+
308
+ /** Will select an option if shift was pressed while navigating to the option */
309
+ const isArrow = ( keyCode === UP_ARROW || keyCode === DOWN_ARROW ) ;
310
+ if ( isArrow && event . shiftKey && previousActiveIndex !== this . _listKeyManager . activeItemIndex ) {
311
+ this . _toggleActiveOption ( ) ;
312
+ }
303
313
}
304
314
305
315
/** Emits a selection change event, called when an option has its selected state changed. */
0 commit comments