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 {
214
214
/** Closes the menu. */
215
215
closeMenu ( ) : void {
216
216
if ( this . _overlayRef && this . menuOpen ) {
217
+ this . _resetMenu ( ) ;
217
218
this . _overlayRef . detach ( ) ;
218
219
this . _closeSubscription . unsubscribe ( ) ;
219
- this . _resetMenu ( ) ;
220
+ this . menu . close . emit ( ) ;
220
221
221
222
if ( this . menu instanceof MdMenu ) {
222
223
this . menu . _resetAnimation ( ) ;
Original file line number Diff line number Diff line change @@ -961,6 +961,28 @@ describe('MdMenu', () => {
961
961
. not . toContain ( 'mat-elevation-z3' , 'Expected no stacked elevation.' ) ;
962
962
} ) ;
963
963
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
+
964
986
} ) ;
965
987
966
988
} ) ;
You can’t perform that action at this time.
0 commit comments