@@ -612,7 +612,7 @@ describe('MatMenu', () => {
612
612
let panel = overlayContainerElement . querySelector ( '.mat-menu-panel' ) as HTMLElement ;
613
613
614
614
expect ( Math . floor ( panel . getBoundingClientRect ( ) . bottom ) )
615
- . toBe ( Math . floor ( trigger . getBoundingClientRect ( ) . bottom ) , 'Expected menu to open above' ) ;
615
+ . toBe ( Math . floor ( trigger . getBoundingClientRect ( ) . top ) , 'Expected menu to open above' ) ;
616
616
617
617
fixture . componentInstance . trigger . closeMenu ( ) ;
618
618
fixture . detectChanges ( ) ;
@@ -625,7 +625,7 @@ describe('MatMenu', () => {
625
625
panel = overlayContainerElement . querySelector ( '.mat-menu-panel' ) as HTMLElement ;
626
626
627
627
expect ( Math . floor ( panel . getBoundingClientRect ( ) . top ) )
628
- . toBe ( Math . floor ( trigger . getBoundingClientRect ( ) . top ) , 'Expected menu to open below' ) ;
628
+ . toBe ( Math . floor ( trigger . getBoundingClientRect ( ) . bottom ) , 'Expected menu to open below' ) ;
629
629
} ) ;
630
630
631
631
} ) ;
@@ -658,7 +658,7 @@ describe('MatMenu', () => {
658
658
659
659
// The y-position of the overlay should be unaffected, as it can already fit vertically
660
660
expect ( Math . floor ( overlayRect . top ) )
661
- . toBe ( Math . floor ( triggerRect . top ) ,
661
+ . toBe ( Math . floor ( triggerRect . bottom ) ,
662
662
`Expected menu top position to be unchanged if it can fit in the viewport.` ) ;
663
663
} ) ;
664
664
@@ -678,11 +678,8 @@ describe('MatMenu', () => {
678
678
const triggerRect = trigger . getBoundingClientRect ( ) ;
679
679
const overlayRect = overlayPane . getBoundingClientRect ( ) ;
680
680
681
- // In "above" position, the bottom edges of the overlay and the origin are aligned.
682
- // To find the overlay top, subtract the menu height from the origin's bottom edge.
683
- const expectedTop = triggerRect . bottom - overlayRect . height ;
684
- expect ( Math . floor ( overlayRect . top ) )
685
- . toBe ( Math . floor ( expectedTop ) ,
681
+ expect ( Math . floor ( overlayRect . bottom ) )
682
+ . toBe ( Math . floor ( triggerRect . top ) ,
686
683
`Expected menu to open in "above" position if "below" position wouldn't fit.` ) ;
687
684
688
685
// The x-position of the overlay should be unaffected, as it can already fit horizontally
@@ -709,14 +706,13 @@ describe('MatMenu', () => {
709
706
const overlayRect = overlayPane . getBoundingClientRect ( ) ;
710
707
711
708
const expectedLeft = triggerRect . right - overlayRect . width ;
712
- const expectedTop = triggerRect . bottom - overlayRect . height ;
713
709
714
710
expect ( Math . floor ( overlayRect . left ) )
715
711
. toBe ( Math . floor ( expectedLeft ) ,
716
712
`Expected menu to open in "before" position if "after" position wouldn't fit.` ) ;
717
713
718
- expect ( Math . floor ( overlayRect . top ) )
719
- . toBe ( Math . floor ( expectedTop ) ,
714
+ expect ( Math . floor ( overlayRect . bottom ) )
715
+ . toBe ( Math . floor ( triggerRect . top ) ,
720
716
`Expected menu to open in "above" position if "below" position wouldn't fit.` ) ;
721
717
} ) ;
722
718
@@ -740,7 +736,7 @@ describe('MatMenu', () => {
740
736
// As designated "above" position won't fit on screen, the menu should fall back
741
737
// to "below" mode, where the top edges of the overlay and trigger are aligned.
742
738
expect ( Math . floor ( overlayRect . top ) )
743
- . toBe ( Math . floor ( triggerRect . top ) ,
739
+ . toBe ( Math . floor ( triggerRect . bottom ) ,
744
740
`Expected menu to open in "below" position if "above" position wouldn't fit.` ) ;
745
741
} ) ;
746
742
@@ -1403,11 +1399,11 @@ describe('MatMenu', () => {
1403
1399
const menus = overlay . querySelectorAll ( '.mat-menu-panel' ) ;
1404
1400
1405
1401
expect ( menus [ 0 ] . classList )
1406
- . toContain ( 'mat-elevation-z2 ' , 'Expected root menu to have base elevation.' ) ;
1402
+ . toContain ( 'mat-elevation-z4 ' , 'Expected root menu to have base elevation.' ) ;
1407
1403
expect ( menus [ 1 ] . classList )
1408
- . toContain ( 'mat-elevation-z3 ' , 'Expected first sub-menu to have base elevation + 1.' ) ;
1404
+ . toContain ( 'mat-elevation-z5 ' , 'Expected first sub-menu to have base elevation + 1.' ) ;
1409
1405
expect ( menus [ 2 ] . classList )
1410
- . toContain ( 'mat-elevation-z4 ' , 'Expected second sub-menu to have base elevation + 2.' ) ;
1406
+ . toContain ( 'mat-elevation-z6 ' , 'Expected second sub-menu to have base elevation + 2.' ) ;
1411
1407
} ) ;
1412
1408
1413
1409
it ( 'should update the elevation when the same menu is opened at a different depth' ,
@@ -1425,7 +1421,7 @@ describe('MatMenu', () => {
1425
1421
let lastMenu = overlay . querySelectorAll ( '.mat-menu-panel' ) [ 2 ] ;
1426
1422
1427
1423
expect ( lastMenu . classList )
1428
- . toContain ( 'mat-elevation-z4 ' , 'Expected menu to have the base elevation plus two.' ) ;
1424
+ . toContain ( 'mat-elevation-z6 ' , 'Expected menu to have the base elevation plus two.' ) ;
1429
1425
1430
1426
( overlay . querySelector ( '.cdk-overlay-backdrop' ) ! as HTMLElement ) . click ( ) ;
1431
1427
fixture . detectChanges ( ) ;
@@ -1441,9 +1437,9 @@ describe('MatMenu', () => {
1441
1437
lastMenu = overlay . querySelector ( '.mat-menu-panel' ) as HTMLElement ;
1442
1438
1443
1439
expect ( lastMenu . classList )
1444
- . not . toContain ( 'mat-elevation-z4 ' , 'Expected menu not to maintain old elevation.' ) ;
1440
+ . not . toContain ( 'mat-elevation-z6 ' , 'Expected menu not to maintain old elevation.' ) ;
1445
1441
expect ( lastMenu . classList )
1446
- . toContain ( 'mat-elevation-z2 ' , 'Expected menu to have the proper updated elevation.' ) ;
1442
+ . toContain ( 'mat-elevation-z4 ' , 'Expected menu to have the proper updated elevation.' ) ;
1447
1443
} ) ) ;
1448
1444
1449
1445
it ( 'should not increase the elevation if the user specified a custom one' , ( ) => {
@@ -1666,7 +1662,7 @@ describe('MatMenu default overrides', () => {
1666
1662
declarations : [ SimpleMenu , FakeIcon ] ,
1667
1663
providers : [ {
1668
1664
provide : MAT_MENU_DEFAULT_OPTIONS ,
1669
- useValue : { overlapTrigger : false , xPosition : 'before' , yPosition : 'above' } ,
1665
+ useValue : { overlapTrigger : true , xPosition : 'before' , yPosition : 'above' } ,
1670
1666
} ] ,
1671
1667
} ) . compileComponents ( ) ;
1672
1668
} ) ) ;
@@ -1676,7 +1672,7 @@ describe('MatMenu default overrides', () => {
1676
1672
fixture . detectChanges ( ) ;
1677
1673
const menu = fixture . componentInstance . menu ;
1678
1674
1679
- expect ( menu . overlapTrigger ) . toBe ( false ) ;
1675
+ expect ( menu . overlapTrigger ) . toBe ( true ) ;
1680
1676
expect ( menu . xPosition ) . toBe ( 'before' ) ;
1681
1677
expect ( menu . yPosition ) . toBe ( 'above' ) ;
1682
1678
} ) ;
0 commit comments