File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -214,9 +214,10 @@ export class MdMenuTrigger implements AfterViewInit, OnDestroy {
214214 /** Closes the menu. */
215215 closeMenu ( ) : void {
216216 if ( this . _overlayRef && this . menuOpen ) {
217+ this . _resetMenu ( ) ;
217218 this . _overlayRef . detach ( ) ;
218219 this . _closeSubscription . unsubscribe ( ) ;
219- this . _resetMenu ( ) ;
220+ this . menu . close . emit ( ) ;
220221
221222 if ( this . menu instanceof MdMenu ) {
222223 this . menu . _resetAnimation ( ) ;
Original file line number Diff line number Diff line change @@ -961,6 +961,28 @@ describe('MdMenu', () => {
961961 . not . toContain ( 'mat-elevation-z3' , 'Expected no stacked elevation.' ) ;
962962 } ) ;
963963
964+ it ( 'should close all of the menus when the root is closed programmatically' , ( ) => {
965+ compileTestComponent ( ) ;
966+ instance . rootTrigger . openMenu ( ) ;
967+ fixture . detectChanges ( ) ;
968+
969+ instance . levelOneTrigger . openMenu ( ) ;
970+ fixture . detectChanges ( ) ;
971+
972+ instance . levelTwoTrigger . openMenu ( ) ;
973+ fixture . detectChanges ( ) ;
974+
975+ const menus = overlay . querySelectorAll ( '.mat-menu-panel' ) ;
976+
977+ expect ( menus . length ) . toBe ( 3 , 'Expected three open menus' ) ;
978+
979+ instance . rootTrigger . closeMenu ( ) ;
980+ fixture . detectChanges ( ) ;
981+
982+ expect ( overlay . querySelectorAll ( '.mat-menu-panel' ) . length ) . toBe ( 0 , 'Expected no open menus' ) ;
983+ } ) ;
984+
985+
964986 } ) ;
965987
966988} ) ;
You can’t perform that action at this time.
0 commit comments