@@ -384,6 +384,7 @@ describe('MatMenu', () => {
384
384
it ( 'should transfer any custom classes from the host to the overlay' , ( ) => {
385
385
const fixture = createComponent ( SimpleMenu , [ ] , [ FakeIcon ] ) ;
386
386
387
+ fixture . componentInstance . panelClass = 'custom-one custom-two' ;
387
388
fixture . detectChanges ( ) ;
388
389
fixture . componentInstance . trigger . openMenu ( ) ;
389
390
fixture . detectChanges ( ) ;
@@ -398,6 +399,28 @@ describe('MatMenu', () => {
398
399
expect ( panel . classList ) . toContain ( 'custom-two' ) ;
399
400
} ) ;
400
401
402
+ it ( 'should not remove mat-elevation class from overlay when panelClass is changed' , ( ) => {
403
+ const fixture = createComponent ( SimpleMenu , [ ] , [ FakeIcon ] ) ;
404
+
405
+ fixture . componentInstance . panelClass = 'custom-one' ;
406
+ fixture . detectChanges ( ) ;
407
+ fixture . componentInstance . trigger . openMenu ( ) ;
408
+ fixture . detectChanges ( ) ;
409
+
410
+ const panel = overlayContainerElement . querySelector ( '.mat-menu-panel' ) ! ;
411
+
412
+ expect ( panel . classList ) . toContain ( 'custom-one' ) ;
413
+ expect ( panel . classList ) . toContain ( 'mat-elevation-z4' ) ;
414
+
415
+ fixture . componentInstance . panelClass = 'custom-two' ;
416
+ fixture . detectChanges ( ) ;
417
+
418
+ expect ( panel . classList ) . not . toContain ( 'custom-one' ) ;
419
+ expect ( panel . classList ) . toContain ( 'custom-two' ) ;
420
+ expect ( panel . classList )
421
+ . toContain ( 'mat-elevation-z4' , 'Expected mat-elevation-z4 not to be removed' ) ;
422
+ } ) ;
423
+
401
424
it ( 'should set the "menu" role on the overlay panel' , ( ) => {
402
425
const fixture = createComponent ( SimpleMenu , [ ] , [ FakeIcon ] ) ;
403
426
fixture . detectChanges ( ) ;
@@ -1858,7 +1881,7 @@ describe('MatMenu default overrides', () => {
1858
1881
<button [matMenuTriggerFor]="menu" #triggerEl>Toggle menu</button>
1859
1882
<mat-menu
1860
1883
#menu="matMenu"
1861
- class="custom-one custom-two "
1884
+ [ class]="panelClass "
1862
1885
(closed)="closeCallback($event)"
1863
1886
[backdropClass]="backdropClass">
1864
1887
@@ -1880,6 +1903,7 @@ class SimpleMenu {
1880
1903
extraItems : string [ ] = [ ] ;
1881
1904
closeCallback = jasmine . createSpy ( 'menu closed callback' ) ;
1882
1905
backdropClass : string ;
1906
+ panelClass : string ;
1883
1907
}
1884
1908
1885
1909
@Component ( {
0 commit comments