Skip to content

Commit

Permalink
feat(module:menu): selected child item, its parent highlight
Browse files Browse the repository at this point in the history
  • Loading branch information
hsuanxyz committed Sep 11, 2017
1 parent 514c2ee commit ae36d86
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/components/menu/nz-submenu.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ export class NzSubMenuComponent implements OnInit, OnDestroy, AfterViewInit {
@Input() nzOpen = false;
@Output() nzOpenChange: EventEmitter<boolean> = new EventEmitter();

get subItemSelected(): boolean {
return !!this.nzMenuComponent.menuItems.find(e => e.selected && e.nzSubMenuComponent === this);
}
get submenuSelected(): boolean {
return !!this.subMenus._results.find(e => e !== this && e.subItemSelected)
}

clickSubMenuTitle() {
if ((this.nzMenuComponent.nzMode === 'inline') || (!this.isInDropDown)) {
this.nzOpen = !this.nzOpen;
Expand Down Expand Up @@ -106,12 +113,16 @@ export class NzSubMenuComponent implements OnInit, OnDestroy, AfterViewInit {
return this.isInDropDown && (this.nzMenuComponent.nzMode === 'horizontal');
}


@HostBinding('class.ant-menu-submenu')
get setMenuSubmenuClass() {
return !this.isInDropDown;
}

@HostBinding('class.ant-menu-submenu-selected')
get setMenuSubmenuSelectedClass() {
return this.submenuSelected || this.subItemSelected;
}

@HostBinding('class.ant-menu-submenu-vertical')
get setMenuVerticalClass() {
return (!this.isInDropDown) && (this.nzMenuComponent.nzMode === 'vertical');
Expand Down

0 comments on commit ae36d86

Please sign in to comment.