Skip to content

Commit

Permalink
fix(module:menu): submenu should not remain highlighted (#3455)
Browse files Browse the repository at this point in the history
* fix(module:menu): submenu should not remain highlighted

* fix: add unit test

* fix: set isMouseHover when overlay collapse
  • Loading branch information
wenqi73 authored and hsuanxyz committed May 17, 2019
1 parent 80c6ed4 commit fd47605
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 13 additions & 1 deletion components/menu/nz-menu.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,17 @@ describe('menu', () => {
fixture.detectChanges();
expect(nestedCallback).toHaveBeenCalledTimes(1);
});
it('should click menu and other submenu menu not active', fakeAsync(() => {
testComponent.open = true;
fixture.detectChanges();
dispatchFakeEvent(testComponent.menuitem1.nativeElement, 'mouseenter');
fixture.detectChanges();
testComponent.menuitem1.nativeElement.click();
expect(submenu.nativeElement.classList).toContain('ant-menu-submenu-active');
fixture.detectChanges();
tick(500);
expect(submenu.nativeElement.classList).not.toContain('ant-menu-submenu-active');
}));
it('should click submenu menu item close', () => {
testComponent.open = true;
fixture.detectChanges();
Expand Down Expand Up @@ -491,7 +502,7 @@ describe('menu', () => {
<li nz-menu-group>
<span title>Item 2</span>
<ul>
<li nz-menu-item>Option 3</li>
<li nz-menu-item #menuitem1>Option 3</li>
<li nz-menu-item>Option 4</li>
<li nz-submenu nzMenuClassName="nested-submenu" [nzDisabled]="disabled">
<span title>Sub Menu</span>
Expand Down Expand Up @@ -520,6 +531,7 @@ export class NzTestMenuHorizontalComponent {
disabled = false;
@ViewChildren(NzSubMenuComponent) subs: QueryList<NzSubMenuComponent>;
@ViewChild('menuitem', { read: ElementRef }) menuitem: ElementRef;
@ViewChild('menuitem1', { read: ElementRef }) menuitem1: ElementRef;
@ViewChild('disableditem', { read: ElementRef }) disableditem: ElementRef;
}

Expand Down
1 change: 1 addition & 0 deletions components/menu/nz-submenu.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ export class NzSubMenuComponent implements OnInit, OnDestroy, AfterContentInit,
} else if (open && mode === 'vertical') {
this.expandState = 'active';
} else {
this.isMouseHover = false;
this.expandState = 'collapsed';
}
this.overlayPositions =
Expand Down

0 comments on commit fd47605

Please sign in to comment.