@@ -26,7 +26,7 @@ import {
26
26
MatMenuItem ,
27
27
} from './index' ;
28
28
import { MENU_PANEL_TOP_PADDING } from './menu-trigger' ;
29
- import { extendObject } from '@angular/material/core' ;
29
+ import { extendObject , MatRipple } from '@angular/material/core' ;
30
30
import {
31
31
dispatchKeyboardEvent ,
32
32
dispatchMouseEvent ,
@@ -490,29 +490,43 @@ describe('MatMenu', () => {
490
490
} ) ;
491
491
492
492
describe ( 'animations' , ( ) => {
493
- it ( 'should include the ripple on items by default' , ( ) => {
493
+ it ( 'should enable ripples on items by default' , ( ) => {
494
494
const fixture = TestBed . createComponent ( SimpleMenu ) ;
495
495
fixture . detectChanges ( ) ;
496
496
497
497
fixture . componentInstance . trigger . openMenu ( ) ;
498
+
498
499
const item = fixture . debugElement . query ( By . css ( '.mat-menu-item' ) ) ;
499
- const ripple = item . query ( By . css ( '.mat-ripple' ) ) ;
500
+ const ripple = item . query ( By . css ( '.mat-ripple' ) ) . injector . get < MatRipple > ( MatRipple ) ;
500
501
501
- expect ( ripple ) . not . toBeNull ( ) ;
502
+ expect ( ripple . disabled ) . toBe ( false ) ;
502
503
} ) ;
503
504
504
- it ( 'should remove the ripple on disabled items' , ( ) => {
505
+ it ( 'should disable ripples on disabled items' , ( ) => {
505
506
const fixture = TestBed . createComponent ( SimpleMenu ) ;
506
507
fixture . detectChanges ( ) ;
507
508
508
509
fixture . componentInstance . trigger . openMenu ( ) ;
510
+
511
+ // The second menu item in the `SimpleMenu` component is disabled.
509
512
const items = fixture . debugElement . queryAll ( By . css ( '.mat-menu-item' ) ) ;
513
+ const ripple = items [ 1 ] . query ( By . css ( '.mat-ripple' ) ) . injector . get < MatRipple > ( MatRipple ) ;
510
514
511
- // items[1] is disabled, so the ripple should not be present
512
- const ripple = items [ 1 ] . query ( By . css ( '.mat-ripple' ) ) ;
513
- expect ( ripple ) . toBeNull ( ) ;
515
+ expect ( ripple . disabled ) . toBe ( true ) ;
514
516
} ) ;
515
517
518
+ it ( 'should disable ripples if disableRipple is set' , ( ) => {
519
+ const fixture = TestBed . createComponent ( SimpleMenu ) ;
520
+ fixture . detectChanges ( ) ;
521
+
522
+ fixture . componentInstance . trigger . openMenu ( ) ;
523
+
524
+ // The third menu item in the `SimpleMenu` component has ripples disabled.
525
+ const items = fixture . debugElement . queryAll ( By . css ( '.mat-menu-item' ) ) ;
526
+ const ripple = items [ 2 ] . query ( By . css ( '.mat-ripple' ) ) . injector . get < MatRipple > ( MatRipple ) ;
527
+
528
+ expect ( ripple . disabled ) . toBe ( true ) ;
529
+ } ) ;
516
530
} ) ;
517
531
518
532
describe ( 'close event' , ( ) => {
@@ -1115,7 +1129,7 @@ describe('MatMenu default overrides', () => {
1115
1129
<mat-menu class="custom-one custom-two" #menu="matMenu" (closed)="closeCallback($event)">
1116
1130
<button mat-menu-item> Item </button>
1117
1131
<button mat-menu-item disabled> Disabled </button>
1118
- <button mat-menu-item>
1132
+ <button mat-menu-item disableRipple >
1119
1133
<fake-icon>unicorn</fake-icon>
1120
1134
Item with an icon
1121
1135
</button>
0 commit comments