@@ -625,7 +625,7 @@ describe('MatMenu', () => {
625
625
let panel = overlayContainerElement . querySelector ( '.mat-menu-panel' ) as HTMLElement ;
626
626
627
627
expect ( Math . floor ( panel . getBoundingClientRect ( ) . bottom ) )
628
- . toBe ( Math . floor ( trigger . getBoundingClientRect ( ) . bottom ) , 'Expected menu to open above' ) ;
628
+ . toBe ( Math . floor ( trigger . getBoundingClientRect ( ) . top ) , 'Expected menu to open above' ) ;
629
629
630
630
fixture . componentInstance . trigger . closeMenu ( ) ;
631
631
fixture . detectChanges ( ) ;
@@ -638,7 +638,7 @@ describe('MatMenu', () => {
638
638
panel = overlayContainerElement . querySelector ( '.mat-menu-panel' ) as HTMLElement ;
639
639
640
640
expect ( Math . floor ( panel . getBoundingClientRect ( ) . top ) )
641
- . toBe ( Math . floor ( trigger . getBoundingClientRect ( ) . top ) , 'Expected menu to open below' ) ;
641
+ . toBe ( Math . floor ( trigger . getBoundingClientRect ( ) . bottom ) , 'Expected menu to open below' ) ;
642
642
} ) ;
643
643
644
644
} ) ;
@@ -671,7 +671,7 @@ describe('MatMenu', () => {
671
671
672
672
// The y-position of the overlay should be unaffected, as it can already fit vertically
673
673
expect ( Math . floor ( overlayRect . top ) )
674
- . toBe ( Math . floor ( triggerRect . top ) ,
674
+ . toBe ( Math . floor ( triggerRect . bottom ) ,
675
675
`Expected menu top position to be unchanged if it can fit in the viewport.` ) ;
676
676
} ) ;
677
677
@@ -691,11 +691,8 @@ describe('MatMenu', () => {
691
691
const triggerRect = trigger . getBoundingClientRect ( ) ;
692
692
const overlayRect = overlayPane . getBoundingClientRect ( ) ;
693
693
694
- // In "above" position, the bottom edges of the overlay and the origin are aligned.
695
- // To find the overlay top, subtract the menu height from the origin's bottom edge.
696
- const expectedTop = triggerRect . bottom - overlayRect . height ;
697
- expect ( Math . floor ( overlayRect . top ) )
698
- . toBe ( Math . floor ( expectedTop ) ,
694
+ expect ( Math . floor ( overlayRect . bottom ) )
695
+ . toBe ( Math . floor ( triggerRect . top ) ,
699
696
`Expected menu to open in "above" position if "below" position wouldn't fit.` ) ;
700
697
701
698
// The x-position of the overlay should be unaffected, as it can already fit horizontally
@@ -722,14 +719,13 @@ describe('MatMenu', () => {
722
719
const overlayRect = overlayPane . getBoundingClientRect ( ) ;
723
720
724
721
const expectedLeft = triggerRect . right - overlayRect . width ;
725
- const expectedTop = triggerRect . bottom - overlayRect . height ;
726
722
727
723
expect ( Math . floor ( overlayRect . left ) )
728
724
. toBe ( Math . floor ( expectedLeft ) ,
729
725
`Expected menu to open in "before" position if "after" position wouldn't fit.` ) ;
730
726
731
- expect ( Math . floor ( overlayRect . top ) )
732
- . toBe ( Math . floor ( expectedTop ) ,
727
+ expect ( Math . floor ( overlayRect . bottom ) )
728
+ . toBe ( Math . floor ( triggerRect . top ) ,
733
729
`Expected menu to open in "above" position if "below" position wouldn't fit.` ) ;
734
730
} ) ;
735
731
@@ -753,7 +749,7 @@ describe('MatMenu', () => {
753
749
// As designated "above" position won't fit on screen, the menu should fall back
754
750
// to "below" mode, where the top edges of the overlay and trigger are aligned.
755
751
expect ( Math . floor ( overlayRect . top ) )
756
- . toBe ( Math . floor ( triggerRect . top ) ,
752
+ . toBe ( Math . floor ( triggerRect . bottom ) ,
757
753
`Expected menu to open in "below" position if "above" position wouldn't fit.` ) ;
758
754
} ) ;
759
755
@@ -1416,11 +1412,11 @@ describe('MatMenu', () => {
1416
1412
const menus = overlay . querySelectorAll ( '.mat-menu-panel' ) ;
1417
1413
1418
1414
expect ( menus [ 0 ] . classList )
1419
- . toContain ( 'mat-elevation-z2 ' , 'Expected root menu to have base elevation.' ) ;
1415
+ . toContain ( 'mat-elevation-z4 ' , 'Expected root menu to have base elevation.' ) ;
1420
1416
expect ( menus [ 1 ] . classList )
1421
- . toContain ( 'mat-elevation-z3 ' , 'Expected first sub-menu to have base elevation + 1.' ) ;
1417
+ . toContain ( 'mat-elevation-z5 ' , 'Expected first sub-menu to have base elevation + 1.' ) ;
1422
1418
expect ( menus [ 2 ] . classList )
1423
- . toContain ( 'mat-elevation-z4 ' , 'Expected second sub-menu to have base elevation + 2.' ) ;
1419
+ . toContain ( 'mat-elevation-z6 ' , 'Expected second sub-menu to have base elevation + 2.' ) ;
1424
1420
} ) ;
1425
1421
1426
1422
it ( 'should update the elevation when the same menu is opened at a different depth' ,
@@ -1438,7 +1434,7 @@ describe('MatMenu', () => {
1438
1434
let lastMenu = overlay . querySelectorAll ( '.mat-menu-panel' ) [ 2 ] ;
1439
1435
1440
1436
expect ( lastMenu . classList )
1441
- . toContain ( 'mat-elevation-z4 ' , 'Expected menu to have the base elevation plus two.' ) ;
1437
+ . toContain ( 'mat-elevation-z6 ' , 'Expected menu to have the base elevation plus two.' ) ;
1442
1438
1443
1439
( overlay . querySelector ( '.cdk-overlay-backdrop' ) ! as HTMLElement ) . click ( ) ;
1444
1440
fixture . detectChanges ( ) ;
@@ -1454,9 +1450,9 @@ describe('MatMenu', () => {
1454
1450
lastMenu = overlay . querySelector ( '.mat-menu-panel' ) as HTMLElement ;
1455
1451
1456
1452
expect ( lastMenu . classList )
1457
- . not . toContain ( 'mat-elevation-z4 ' , 'Expected menu not to maintain old elevation.' ) ;
1453
+ . not . toContain ( 'mat-elevation-z6 ' , 'Expected menu not to maintain old elevation.' ) ;
1458
1454
expect ( lastMenu . classList )
1459
- . toContain ( 'mat-elevation-z2 ' , 'Expected menu to have the proper updated elevation.' ) ;
1455
+ . toContain ( 'mat-elevation-z4 ' , 'Expected menu to have the proper updated elevation.' ) ;
1460
1456
} ) ) ;
1461
1457
1462
1458
it ( 'should not increase the elevation if the user specified a custom one' , ( ) => {
@@ -1679,7 +1675,7 @@ describe('MatMenu default overrides', () => {
1679
1675
declarations : [ SimpleMenu , FakeIcon ] ,
1680
1676
providers : [ {
1681
1677
provide : MAT_MENU_DEFAULT_OPTIONS ,
1682
- useValue : { overlapTrigger : false , xPosition : 'before' , yPosition : 'above' } ,
1678
+ useValue : { overlapTrigger : true , xPosition : 'before' , yPosition : 'above' } ,
1683
1679
} ] ,
1684
1680
} ) . compileComponents ( ) ;
1685
1681
} ) ) ;
@@ -1689,7 +1685,7 @@ describe('MatMenu default overrides', () => {
1689
1685
fixture . detectChanges ( ) ;
1690
1686
const menu = fixture . componentInstance . menu ;
1691
1687
1692
- expect ( menu . overlapTrigger ) . toBe ( false ) ;
1688
+ expect ( menu . overlapTrigger ) . toBe ( true ) ;
1693
1689
expect ( menu . xPosition ) . toBe ( 'before' ) ;
1694
1690
expect ( menu . yPosition ) . toBe ( 'above' ) ;
1695
1691
} ) ;
0 commit comments