@@ -129,8 +129,8 @@ export class MatAutocompleteTrigger implements ControlValueAccessor, OnDestroy {
129129 /** The subscription for closing actions (some are bound to document). */
130130 private _closingActionsSubscription : Subscription ;
131131
132- /** Stream of escape keyboard events. */
133- private _escapeEventStream = new Subject < void > ( ) ;
132+ /** Stream of keyboard events that can close the panel . */
133+ private _closeKeyEventStream = new Subject < void > ( ) ;
134134
135135 /** View -> model callback called when value changes */
136136 _onChange : ( value : any ) => void = ( ) => { } ;
@@ -152,7 +152,7 @@ export class MatAutocompleteTrigger implements ControlValueAccessor, OnDestroy {
152152
153153 ngOnDestroy ( ) {
154154 this . _destroyPanel ( ) ;
155- this . _escapeEventStream . complete ( ) ;
155+ this . _closeKeyEventStream . complete ( ) ;
156156 }
157157
158158 /** Whether or not the autocomplete panel is open. */
@@ -194,7 +194,7 @@ export class MatAutocompleteTrigger implements ControlValueAccessor, OnDestroy {
194194 return merge (
195195 this . optionSelections ,
196196 this . autocomplete . _keyManager . tabOut . pipe ( filter ( ( ) => this . _panelOpen ) ) ,
197- this . _escapeEventStream ,
197+ this . _closeKeyEventStream ,
198198 this . _outsideClickStream ,
199199 this . _overlayRef ?
200200 this . _overlayRef . detachments ( ) . pipe ( filter ( ( ) => this . _panelOpen ) ) :
@@ -289,9 +289,11 @@ export class MatAutocompleteTrigger implements ControlValueAccessor, OnDestroy {
289289 _handleKeydown ( event : KeyboardEvent ) : void {
290290 const keyCode = event . keyCode ;
291291
292- if ( keyCode === ESCAPE && this . panelOpen ) {
292+ // Close when pressing ESCAPE or ALT + UP_ARROW, based on the a11y guidelines.
293+ // See: https://www.w3.org/TR/wai-aria-practices-1.1/#textbox-keyboard-interaction
294+ if ( this . panelOpen && ( keyCode === ESCAPE || ( keyCode === UP_ARROW && event . altKey ) ) ) {
293295 this . _resetActiveItem ( ) ;
294- this . _escapeEventStream . next ( ) ;
296+ this . _closeKeyEventStream . next ( ) ;
295297 event . stopPropagation ( ) ;
296298 } else if ( this . activeOption && keyCode === ENTER && this . panelOpen ) {
297299 this . activeOption . _selectViaInteraction ( ) ;
0 commit comments