From a07496d8017847d2b9f236aeb851c5edc98cd589 Mon Sep 17 00:00:00 2001 From: Nikita Poltoratsky Date: Sat, 19 May 2018 12:26:13 +0300 Subject: [PATCH] fix(popover): hide when host was removed (#430) --- e2e/popover.e2e-spec.ts | 9 +++++++++ .../theme/components/popover/popover.directive.ts | 1 + 2 files changed, 10 insertions(+) diff --git a/e2e/popover.e2e-spec.ts b/e2e/popover.e2e-spec.ts index 12c0a5aa35..93f985c707 100644 --- a/e2e/popover.e2e-spec.ts +++ b/e2e/popover.e2e-spec.ts @@ -164,4 +164,13 @@ describe('nb-popover', () => { const text = element(popover).element(by.css('nb-dynamic-to-add > div > strong')).getText(); expect(text).toEqual('hello from dynamically inserted component: Example context'); }); + + it('have to hide popover when host removed', done => { + element(contentTemplate).click(); + expect(element(popover).isPresent()).toBeTruthy(); + browser.get('#/').then(() => { + expect(element(popover).isPresent()).toBeFalsy(); + done(); + }) + }); }); diff --git a/src/framework/theme/components/popover/popover.directive.ts b/src/framework/theme/components/popover/popover.directive.ts index 7391ac5a25..5ab030698f 100644 --- a/src/framework/theme/components/popover/popover.directive.ts +++ b/src/framework/theme/components/popover/popover.directive.ts @@ -167,6 +167,7 @@ export class NbPopoverDirective implements OnInit, OnDestroy { ngOnDestroy() { this.alive = false; + this.hide(); } /**