@@ -625,7 +625,7 @@ describe('MatMenu', () => {
625625 let panel = overlayContainerElement . querySelector ( '.mat-menu-panel' ) as HTMLElement ;
626626
627627 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' ) ;
629629
630630 fixture . componentInstance . trigger . closeMenu ( ) ;
631631 fixture . detectChanges ( ) ;
@@ -638,7 +638,7 @@ describe('MatMenu', () => {
638638 panel = overlayContainerElement . querySelector ( '.mat-menu-panel' ) as HTMLElement ;
639639
640640 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' ) ;
642642 } ) ;
643643
644644 } ) ;
@@ -671,7 +671,7 @@ describe('MatMenu', () => {
671671
672672 // The y-position of the overlay should be unaffected, as it can already fit vertically
673673 expect ( Math . floor ( overlayRect . top ) )
674- . toBe ( Math . floor ( triggerRect . top ) ,
674+ . toBe ( Math . floor ( triggerRect . bottom ) ,
675675 `Expected menu top position to be unchanged if it can fit in the viewport.` ) ;
676676 } ) ;
677677
@@ -691,11 +691,8 @@ describe('MatMenu', () => {
691691 const triggerRect = trigger . getBoundingClientRect ( ) ;
692692 const overlayRect = overlayPane . getBoundingClientRect ( ) ;
693693
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 ) ,
699696 `Expected menu to open in "above" position if "below" position wouldn't fit.` ) ;
700697
701698 // The x-position of the overlay should be unaffected, as it can already fit horizontally
@@ -722,14 +719,13 @@ describe('MatMenu', () => {
722719 const overlayRect = overlayPane . getBoundingClientRect ( ) ;
723720
724721 const expectedLeft = triggerRect . right - overlayRect . width ;
725- const expectedTop = triggerRect . bottom - overlayRect . height ;
726722
727723 expect ( Math . floor ( overlayRect . left ) )
728724 . toBe ( Math . floor ( expectedLeft ) ,
729725 `Expected menu to open in "before" position if "after" position wouldn't fit.` ) ;
730726
731- expect ( Math . floor ( overlayRect . top ) )
732- . toBe ( Math . floor ( expectedTop ) ,
727+ expect ( Math . floor ( overlayRect . bottom ) )
728+ . toBe ( Math . floor ( triggerRect . top ) ,
733729 `Expected menu to open in "above" position if "below" position wouldn't fit.` ) ;
734730 } ) ;
735731
@@ -753,7 +749,7 @@ describe('MatMenu', () => {
753749 // As designated "above" position won't fit on screen, the menu should fall back
754750 // to "below" mode, where the top edges of the overlay and trigger are aligned.
755751 expect ( Math . floor ( overlayRect . top ) )
756- . toBe ( Math . floor ( triggerRect . top ) ,
752+ . toBe ( Math . floor ( triggerRect . bottom ) ,
757753 `Expected menu to open in "below" position if "above" position wouldn't fit.` ) ;
758754 } ) ;
759755
@@ -1416,11 +1412,11 @@ describe('MatMenu', () => {
14161412 const menus = overlay . querySelectorAll ( '.mat-menu-panel' ) ;
14171413
14181414 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.' ) ;
14201416 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.' ) ;
14221418 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.' ) ;
14241420 } ) ;
14251421
14261422 it ( 'should update the elevation when the same menu is opened at a different depth' ,
@@ -1438,7 +1434,7 @@ describe('MatMenu', () => {
14381434 let lastMenu = overlay . querySelectorAll ( '.mat-menu-panel' ) [ 2 ] ;
14391435
14401436 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.' ) ;
14421438
14431439 ( overlay . querySelector ( '.cdk-overlay-backdrop' ) ! as HTMLElement ) . click ( ) ;
14441440 fixture . detectChanges ( ) ;
@@ -1454,9 +1450,9 @@ describe('MatMenu', () => {
14541450 lastMenu = overlay . querySelector ( '.mat-menu-panel' ) as HTMLElement ;
14551451
14561452 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.' ) ;
14581454 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.' ) ;
14601456 } ) ) ;
14611457
14621458 it ( 'should not increase the elevation if the user specified a custom one' , ( ) => {
@@ -1679,7 +1675,7 @@ describe('MatMenu default overrides', () => {
16791675 declarations : [ SimpleMenu , FakeIcon ] ,
16801676 providers : [ {
16811677 provide : MAT_MENU_DEFAULT_OPTIONS ,
1682- useValue : { overlapTrigger : false , xPosition : 'before' , yPosition : 'above' } ,
1678+ useValue : { overlapTrigger : true , xPosition : 'before' , yPosition : 'above' } ,
16831679 } ] ,
16841680 } ) . compileComponents ( ) ;
16851681 } ) ) ;
@@ -1689,7 +1685,7 @@ describe('MatMenu default overrides', () => {
16891685 fixture . detectChanges ( ) ;
16901686 const menu = fixture . componentInstance . menu ;
16911687
1692- expect ( menu . overlapTrigger ) . toBe ( false ) ;
1688+ expect ( menu . overlapTrigger ) . toBe ( true ) ;
16931689 expect ( menu . xPosition ) . toBe ( 'before' ) ;
16941690 expect ( menu . yPosition ) . toBe ( 'above' ) ;
16951691 } ) ;
0 commit comments