diff --git a/e2e/menu.e2e-spec.ts b/e2e/menu.e2e-spec.ts index 5df97b0bc9..2674e464d1 100644 --- a/e2e/menu.e2e-spec.ts +++ b/e2e/menu.e2e-spec.ts @@ -23,7 +23,8 @@ const menu333 = by.css('#menu-first ul li:nth-child(4) ul li:nth-child(3) ul li: const newMenu = by.css('#menu-first ul li:nth-child(5) a'); const addButton = by.css('#addBtn'); const homeButton = by.css('#homeBtn'); - +const hiddenMenuItem = by.css('#menu-second ul li:nth-child(3)'); +const hiddenSubmenuItem = by.css('#menu-second ul li:nth-child(2) ul li:nth-child(2)'); const waitTime = 20 * 1000; const sidebarMenu31 = by.css('#menu-sidebar ul li:nth-child(4) ul li:nth-child(1) > a > span'); @@ -277,6 +278,14 @@ describe('nb-menu', () => { }); }); + it('hidden menu item should not be present', () => { + expect(element(hiddenMenuItem).isPresent()).toBeFalsy(); + }); + + it('hidden submenu item should not be present', () => { + expect(element(hiddenSubmenuItem).isPresent()).toBeFalsy(); + }) + it('should add query string to url', () => { element.all(menu1).first().click() .then(() => { diff --git a/src/app/menu-test/menu-test.component.ts b/src/app/menu-test/menu-test.component.ts index 3625544897..7cb124542a 100644 --- a/src/app/menu-test/menu-test.component.ts +++ b/src/app/menu-test/menu-test.component.ts @@ -96,6 +96,11 @@ export class NbMenuItem4Component { } + + + + + `, @@ -120,6 +125,28 @@ export class NbMenuTestComponent implements OnInit, OnDestroy { }, ]; + menuItems1 = [ + { + title: 'Menu #1', + }, + { + title: 'Menu #2', + children: [ + { + title: 'Menu #2.1', + }, + { + title: 'Hidden Submenu Item', + hidden: true, + }, + ], + }, + { + title: 'Hidden Menu Item', + hidden: true, + }, + ]; + private alive: boolean = true; constructor(private menuService: NbMenuService) { } @@ -182,17 +209,17 @@ export class NbMenuTestComponent implements OnInit, OnDestroy { ], 'firstMenu', ); - } +} - ngOnDestroy() { - this.alive = false; - } +ngOnDestroy() { + this.alive = false; +} - addMenuItem() { - this.menuService.addItems([{ title: 'New Menu Item' }], 'firstMenu'); - } +addMenuItem() { + this.menuService.addItems([{ title: 'New Menu Item' }], 'firstMenu'); +} - navigateHome() { - this.menuService.navigateHome('firstMenu'); - } +navigateHome() { + this.menuService.navigateHome('firstMenu'); +} } diff --git a/src/framework/theme/components/menu/menu-item.component.html b/src/framework/theme/components/menu/menu-item.component.html index 157a22d0f6..f048dad60a 100644 --- a/src/framework/theme/components/menu/menu-item.component.html +++ b/src/framework/theme/components/menu/menu-item.component.html @@ -1,29 +1,29 @@ - + {{ menuItem.title }} - + {{ menuItem.title }} - + {{ menuItem.title }} - {{ menuItem.title }} - {{ menuItem.title }} + [class.ion-chevron-down]="menuItem.expanded"> - diff --git a/src/framework/theme/components/menu/menu.component.ts b/src/framework/theme/components/menu/menu.component.ts index 1eec9219f1..1b88b0a285 100644 --- a/src/framework/theme/components/menu/menu.component.ts +++ b/src/framework/theme/components/menu/menu.component.ts @@ -5,20 +5,20 @@ */ import { - Component, - Input, - Output, - EventEmitter, - OnInit, - OnDestroy, - HostBinding, - ViewChildren, - QueryList, - ElementRef, - AfterViewInit, - PLATFORM_ID, - Inject, - } from '@angular/core'; + Component, + Input, + Output, + EventEmitter, + OnInit, + OnDestroy, + HostBinding, + ViewChildren, + QueryList, + ElementRef, + AfterViewInit, + PLATFORM_ID, + Inject, +} from '@angular/core'; import { isPlatformBrowser } from '@angular/common'; import { Router, NavigationEnd } from '@angular/router'; import { BehaviorSubject } from 'rxjs/BehaviorSubject'; @@ -154,14 +154,17 @@ export class NbMenuItemComponent implements AfterViewInit, OnDestroy { styleUrls: ['./menu.component.scss'], template: ` `, })