@@ -20,7 +20,7 @@ import {
2020} from '@angular/core' ;
2121import { BooleanInput , coerceBooleanProperty } from '@angular/cdk/coercion' ;
2222import { FocusableOption } from '@angular/cdk/a11y' ;
23- import { ENTER , LEFT_ARROW , RIGHT_ARROW , SPACE } from '@angular/cdk/keycodes' ;
23+ import { ENTER , hasModifierKey , LEFT_ARROW , RIGHT_ARROW , SPACE } from '@angular/cdk/keycodes' ;
2424import { Directionality } from '@angular/cdk/bidi' ;
2525import { fromEvent , Subject } from 'rxjs' ;
2626import { filter , takeUntil } from 'rxjs/operators' ;
@@ -64,7 +64,7 @@ export class CdkMenuItem implements FocusableOption, FocusableElement, Toggler,
6464 * The text used to locate this item during menu typeahead. If not specified,
6565 * the `textContent` of the item will be used.
6666 */
67- @Input ( 'cdkMenuItemTypeahead ' ) typeahead : string ;
67+ @Input ( 'cdkMenuitemTypeaheadLabel ' ) typeaheadLabel : string | null ;
6868
6969 /**
7070 * If this MenuItem is a regular MenuItem, outputs when it is triggered by a keyboard or mouse
@@ -113,6 +113,7 @@ export class CdkMenuItem implements FocusableOption, FocusableElement, Toggler,
113113
114114 ngOnDestroy ( ) {
115115 this . destroyed . next ( ) ;
116+ this . destroyed . complete ( ) ;
116117 }
117118
118119 /** Place focus on the element. */
@@ -156,7 +157,7 @@ export class CdkMenuItem implements FocusableOption, FocusableElement, Toggler,
156157
157158 /** Get the label for this element which is required by the FocusableOption interface. */
158159 getLabel ( ) : string {
159- return this . typeahead || this . _elementRef . nativeElement . textContent ?. trim ( ) || '' ;
160+ return this . typeaheadLabel || this . _elementRef . nativeElement . textContent ?. trim ( ) || '' ;
160161 }
161162
162163 /** Reset the tabindex to -1. */
@@ -191,26 +192,32 @@ export class CdkMenuItem implements FocusableOption, FocusableElement, Toggler,
191192 switch ( event . keyCode ) {
192193 case SPACE :
193194 case ENTER :
194- event . preventDefault ( ) ;
195- this . trigger ( { keepOpen : event . keyCode === SPACE && ! this . closeOnSpacebarTrigger } ) ;
195+ if ( ! hasModifierKey ( event ) ) {
196+ event . preventDefault ( ) ;
197+ this . trigger ( { keepOpen : event . keyCode === SPACE && ! this . closeOnSpacebarTrigger } ) ;
198+ }
196199 break ;
197200
198201 case RIGHT_ARROW :
199- if ( this . _parentMenu && this . _isParentVertical ( ) ) {
200- if ( this . _dir ?. value !== 'rtl' ) {
201- this . _forwardArrowPressed ( event ) ;
202- } else {
203- this . _backArrowPressed ( event ) ;
202+ if ( ! hasModifierKey ( event ) ) {
203+ if ( this . _parentMenu && this . _isParentVertical ( ) ) {
204+ if ( this . _dir ?. value !== 'rtl' ) {
205+ this . _forwardArrowPressed ( event ) ;
206+ } else {
207+ this . _backArrowPressed ( event ) ;
208+ }
204209 }
205210 }
206211 break ;
207212
208213 case LEFT_ARROW :
209- if ( this . _parentMenu && this . _isParentVertical ( ) ) {
210- if ( this . _dir ?. value !== 'rtl' ) {
211- this . _backArrowPressed ( event ) ;
212- } else {
213- this . _forwardArrowPressed ( event ) ;
214+ if ( ! hasModifierKey ( event ) ) {
215+ if ( this . _parentMenu && this . _isParentVertical ( ) ) {
216+ if ( this . _dir ?. value !== 'rtl' ) {
217+ this . _backArrowPressed ( event ) ;
218+ } else {
219+ this . _forwardArrowPressed ( event ) ;
220+ }
214221 }
215222 }
216223 break ;
0 commit comments