Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/lib/menu/menu-trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,10 @@ export class MdMenuTrigger implements AfterViewInit, OnDestroy {
/** Closes the menu. */
closeMenu(): void {
if (this._overlayRef && this.menuOpen) {
this._resetMenu();
this._overlayRef.detach();
this._closeSubscription.unsubscribe();
this._resetMenu();
this.menu.close.emit();

if (this.menu instanceof MdMenu) {
this.menu._resetAnimation();
Expand Down
22 changes: 22 additions & 0 deletions src/lib/menu/menu.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,28 @@ describe('MdMenu', () => {
.not.toContain('mat-elevation-z3', 'Expected no stacked elevation.');
});

it('should close all of the menus when the root is closed programmatically', () => {
compileTestComponent();
instance.rootTrigger.openMenu();
fixture.detectChanges();

instance.levelOneTrigger.openMenu();
fixture.detectChanges();

instance.levelTwoTrigger.openMenu();
fixture.detectChanges();

const menus = overlay.querySelectorAll('.mat-menu-panel');

expect(menus.length).toBe(3, 'Expected three open menus');

instance.rootTrigger.closeMenu();
fixture.detectChanges();

expect(overlay.querySelectorAll('.mat-menu-panel').length).toBe(0, 'Expected no open menus');
});


});

});
Expand Down