Skip to content

Commit

Permalink
fix(module:menu): fix submenu not active when collapsed
Browse files Browse the repository at this point in the history
  • Loading branch information
vthinkxie authored and vthinkxie committed Jun 21, 2019
1 parent 98430b6 commit 94ed8a1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
31 changes: 30 additions & 1 deletion components/menu/nz-menu.spec.ts
Expand Up @@ -45,7 +45,8 @@ describe('menu', () => {
NzTestMenuHorizontalComponent,
NzTestMenuInlineComponent,
NzDemoMenuNgForComponent,
NzTestNgIfMenuComponent
NzTestNgIfMenuComponent,
NzTestSubMenuSelectedComponent
],
schemas: [NO_ERRORS_SCHEMA],
providers: [
Expand Down Expand Up @@ -490,6 +491,15 @@ describe('menu', () => {
}).not.toThrowError();
});
});
describe('submenu default selected', () => {
it('should default selected active submenu', () => {
const fixture = TestBed.createComponent(NzTestSubMenuSelectedComponent);
fixture.detectChanges();
expect(fixture.debugElement.nativeElement.querySelector('.ant-menu-submenu').classList).toContain(
'ant-menu-submenu-selected'
);
});
});
});
});

Expand Down Expand Up @@ -712,3 +722,22 @@ export class NzTestNgIfMenuComponent {
text = 'text';
display = true;
}

// https://github.com/NG-ZORRO/ng-zorro-antd/issues/3345
@Component({
template: `
<ul nz-menu nzMode="inline" nzTheme="dark" nzInlineCollapsed>
<li nz-menu-item nz-tooltip nzPlacement="right">
<i nz-icon nzType="mail"></i>
<span>Navigation One</span>
</li>
<li nz-submenu nzTitle="Navigation Two" nzIcon="appstore">
<ul>
<li nz-menu-item nzSelected>Option 5</li>
<li nz-menu-item>Option 6</li>
</ul>
</li>
</ul>
`
})
export class NzTestSubMenuSelectedComponent {}
1 change: 1 addition & 0 deletions components/menu/nz-submenu.component.ts
Expand Up @@ -198,6 +198,7 @@ export class NzSubMenuComponent implements OnInit, OnDestroy, AfterContentInit,
flatMap(() =>
merge(this.listOfNzMenuItemDirective.changes, ...this.listOfNzMenuItemDirective.map(menu => menu.selected$))
),
startWith(true),
map(() => this.listOfNzMenuItemDirective.some(e => e.nzSelected)),
takeUntil(this.destroy$)
)
Expand Down

0 comments on commit 94ed8a1

Please sign in to comment.