Skip to content

Commit

Permalink
fix(module:menu): fix menu level 4 padding error (#2356)
Browse files Browse the repository at this point in the history
close #2327
  • Loading branch information
vthinkxie authored Oct 25, 2018
1 parent a4a948c commit 7906066
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
11 changes: 9 additions & 2 deletions components/menu/demo/inline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,23 @@ import { Component } from '@angular/core';
<ul>
<li nz-menu-item>Option 7</li>
<li nz-menu-item>Option 8</li>
<li nz-submenu>
<span title>Submenu</span>
<ul>
<li nz-menu-item>Option 9</li>
<li nz-menu-item>Option 10</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li nz-submenu>
<span title><i nz-icon type="setting"></i> Navigation Three</span>
<ul>
<li nz-menu-item>Option 9</li>
<li nz-menu-item>Option 10</li>
<li nz-menu-item>Option 11</li>
<li nz-menu-item>Option 12</li>
<li nz-menu-item>Option 13</li>
</ul>
</li>
</ul>
Expand Down
18 changes: 5 additions & 13 deletions components/menu/nz-submenu.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { animate, state, style, transition, trigger } from '@angular/animations';
import { CdkConnectedOverlay, ConnectedOverlayPositionChange, ConnectionPositionPair } from '@angular/cdk/overlay';
import {
AfterContentInit,
ChangeDetectorRef,
Component,
ContentChildren,
Expand Down Expand Up @@ -89,7 +88,7 @@ import { NzMenuDirective } from './nz-menu.directive';
]
})

export class NzSubMenuComponent implements OnInit, OnDestroy, AfterContentInit {
export class NzSubMenuComponent implements OnInit, OnDestroy {
private _open = false;
private _disabled = false;
private $mouseSubject = new Subject<boolean>();
Expand Down Expand Up @@ -302,23 +301,16 @@ export class NzSubMenuComponent implements OnInit, OnDestroy, AfterContentInit {
}

ngOnInit(): void {
if (this.nzSubMenuComponent) {
this.level = this.nzSubMenuComponent.level + 1;
this.isInSubMenu = true;
}
this.nzMenuDirective.subMenus.push(this);
const $combineAll = combineLatest(this.$subOpen, this.$mouseSubject.asObservable()).pipe(map(value => value[ 0 ] || value[ 1 ]), auditTime(150));
$combineAll.pipe(takeUntil(this.unsubscribe$)).subscribe(this.handleOpenEvent);
this.isInDropDown = this.nzMenuDirective.nzInDropDown;
}

ngAfterContentInit(): void {
if (this.subMenus && this.subMenus.length) {
this.subMenus.filter(x => x !== this).forEach(menu => {
if (this.subMenuMode === 'inline') {
Promise.resolve().then(() => menu.level = this.level + 1);
}
menu.isInSubMenu = true;
});
}
}

ngOnDestroy(): void {
this.unsubscribe$.next();
this.unsubscribe$.complete();
Expand Down

0 comments on commit 7906066

Please sign in to comment.