@@ -612,7 +612,7 @@ describe('MatMenu', () => {
612612 let panel = overlayContainerElement . querySelector ( '.mat-menu-panel' ) as HTMLElement ;
613613
614614 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' ) ;
616616
617617 fixture . componentInstance . trigger . closeMenu ( ) ;
618618 fixture . detectChanges ( ) ;
@@ -625,7 +625,7 @@ describe('MatMenu', () => {
625625 panel = overlayContainerElement . querySelector ( '.mat-menu-panel' ) as HTMLElement ;
626626
627627 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' ) ;
629629 } ) ;
630630
631631 } ) ;
@@ -658,7 +658,7 @@ describe('MatMenu', () => {
658658
659659 // The y-position of the overlay should be unaffected, as it can already fit vertically
660660 expect ( Math . floor ( overlayRect . top ) )
661- . toBe ( Math . floor ( triggerRect . top ) ,
661+ . toBe ( Math . floor ( triggerRect . bottom ) ,
662662 `Expected menu top position to be unchanged if it can fit in the viewport.` ) ;
663663 } ) ;
664664
@@ -678,11 +678,8 @@ describe('MatMenu', () => {
678678 const triggerRect = trigger . getBoundingClientRect ( ) ;
679679 const overlayRect = overlayPane . getBoundingClientRect ( ) ;
680680
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 ) ,
686683 `Expected menu to open in "above" position if "below" position wouldn't fit.` ) ;
687684
688685 // The x-position of the overlay should be unaffected, as it can already fit horizontally
@@ -709,14 +706,13 @@ describe('MatMenu', () => {
709706 const overlayRect = overlayPane . getBoundingClientRect ( ) ;
710707
711708 const expectedLeft = triggerRect . right - overlayRect . width ;
712- const expectedTop = triggerRect . bottom - overlayRect . height ;
713709
714710 expect ( Math . floor ( overlayRect . left ) )
715711 . toBe ( Math . floor ( expectedLeft ) ,
716712 `Expected menu to open in "before" position if "after" position wouldn't fit.` ) ;
717713
718- expect ( Math . floor ( overlayRect . top ) )
719- . toBe ( Math . floor ( expectedTop ) ,
714+ expect ( Math . floor ( overlayRect . bottom ) )
715+ . toBe ( Math . floor ( triggerRect . top ) ,
720716 `Expected menu to open in "above" position if "below" position wouldn't fit.` ) ;
721717 } ) ;
722718
@@ -740,7 +736,7 @@ describe('MatMenu', () => {
740736 // As designated "above" position won't fit on screen, the menu should fall back
741737 // to "below" mode, where the top edges of the overlay and trigger are aligned.
742738 expect ( Math . floor ( overlayRect . top ) )
743- . toBe ( Math . floor ( triggerRect . top ) ,
739+ . toBe ( Math . floor ( triggerRect . bottom ) ,
744740 `Expected menu to open in "below" position if "above" position wouldn't fit.` ) ;
745741 } ) ;
746742
@@ -1403,11 +1399,11 @@ describe('MatMenu', () => {
14031399 const menus = overlay . querySelectorAll ( '.mat-menu-panel' ) ;
14041400
14051401 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.' ) ;
14071403 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.' ) ;
14091405 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.' ) ;
14111407 } ) ;
14121408
14131409 it ( 'should update the elevation when the same menu is opened at a different depth' ,
@@ -1425,7 +1421,7 @@ describe('MatMenu', () => {
14251421 let lastMenu = overlay . querySelectorAll ( '.mat-menu-panel' ) [ 2 ] ;
14261422
14271423 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.' ) ;
14291425
14301426 ( overlay . querySelector ( '.cdk-overlay-backdrop' ) ! as HTMLElement ) . click ( ) ;
14311427 fixture . detectChanges ( ) ;
@@ -1441,9 +1437,9 @@ describe('MatMenu', () => {
14411437 lastMenu = overlay . querySelector ( '.mat-menu-panel' ) as HTMLElement ;
14421438
14431439 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.' ) ;
14451441 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.' ) ;
14471443 } ) ) ;
14481444
14491445 it ( 'should not increase the elevation if the user specified a custom one' , ( ) => {
@@ -1666,7 +1662,7 @@ describe('MatMenu default overrides', () => {
16661662 declarations : [ SimpleMenu , FakeIcon ] ,
16671663 providers : [ {
16681664 provide : MAT_MENU_DEFAULT_OPTIONS ,
1669- useValue : { overlapTrigger : false , xPosition : 'before' , yPosition : 'above' } ,
1665+ useValue : { overlapTrigger : true , xPosition : 'before' , yPosition : 'above' } ,
16701666 } ] ,
16711667 } ) . compileComponents ( ) ;
16721668 } ) ) ;
@@ -1676,7 +1672,7 @@ describe('MatMenu default overrides', () => {
16761672 fixture . detectChanges ( ) ;
16771673 const menu = fixture . componentInstance . menu ;
16781674
1679- expect ( menu . overlapTrigger ) . toBe ( false ) ;
1675+ expect ( menu . overlapTrigger ) . toBe ( true ) ;
16801676 expect ( menu . xPosition ) . toBe ( 'before' ) ;
16811677 expect ( menu . yPosition ) . toBe ( 'above' ) ;
16821678 } ) ;
0 commit comments