From af58d3fdb886752531060c52a5ed82aea88a6142 Mon Sep 17 00:00:00 2001 From: Nikita Poltoratsky Date: Sat, 29 Dec 2018 19:09:34 +0300 Subject: [PATCH] fix(theme): check ref before detaching (#1116) --- .../components/datepicker/datepicker.component.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/framework/theme/components/datepicker/datepicker.component.ts b/src/framework/theme/components/datepicker/datepicker.component.ts index c58f574197..8617b441c9 100644 --- a/src/framework/theme/components/datepicker/datepicker.component.ts +++ b/src/framework/theme/components/datepicker/datepicker.component.ts @@ -209,7 +209,10 @@ export abstract class NbBasePicker extends NbDatepicker implements O ngOnDestroy() { this.alive = false; this.hide(); - this.ref.dispose(); + + if (this.ref) { + this.ref.dispose(); + } } /** @@ -238,7 +241,10 @@ export abstract class NbBasePicker extends NbDatepicker implements O } hide() { - this.ref.detach(); + if (this.ref) { + this.ref.detach(); + } + // save current value if picker was rendered if (this.picker) { this.queue = this.value;