File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ export const MENU_PANEL_TOP_PADDING = 8;
70
70
selector : `[mat-menu-trigger-for], [matMenuTriggerFor]` ,
71
71
host : {
72
72
'aria-haspopup' : 'true' ,
73
+ '[attr.aria-expanded]' : 'menuOpen || null' ,
73
74
'(mousedown)' : '_handleMousedown($event)' ,
74
75
'(keydown)' : '_handleKeydown($event)' ,
75
76
'(click)' : '_handleClick($event)' ,
Original file line number Diff line number Diff line change @@ -388,6 +388,24 @@ describe('MatMenu', () => {
388
388
expect ( items [ 2 ] . classList ) . toContain ( 'cdk-keyboard-focused' ) ;
389
389
} ) ) ;
390
390
391
+ it ( 'should toggle the aria-expanded attribute on the trigger' , ( ) => {
392
+ const fixture = createComponent ( SimpleMenu , [ ] , [ FakeIcon ] ) ;
393
+ fixture . detectChanges ( ) ;
394
+ const triggerEl = fixture . componentInstance . triggerEl . nativeElement ;
395
+
396
+ expect ( triggerEl . hasAttribute ( 'aria-expanded' ) ) . toBe ( false ) ;
397
+
398
+ fixture . componentInstance . trigger . openMenu ( ) ;
399
+ fixture . detectChanges ( ) ;
400
+
401
+ expect ( triggerEl . getAttribute ( 'aria-expanded' ) ) . toBe ( 'true' ) ;
402
+
403
+ fixture . componentInstance . trigger . closeMenu ( ) ;
404
+ fixture . detectChanges ( ) ;
405
+
406
+ expect ( triggerEl . hasAttribute ( 'aria-expanded' ) ) . toBe ( false ) ;
407
+ } ) ;
408
+
391
409
describe ( 'lazy rendering' , ( ) => {
392
410
it ( 'should be able to render the menu content lazily' , fakeAsync ( ( ) => {
393
411
const fixture = createComponent ( SimpleLazyMenu ) ;
You can’t perform that action at this time.
0 commit comments