From 7c12874b8f41f8c9554f87919e0eb2dfa2540701 Mon Sep 17 00:00:00 2001 From: ANDREI PADOLIN Date: Wed, 4 Aug 2021 11:56:24 +0300 Subject: [PATCH] feat(layout): added error message if layout not provided (#2778) --- .../cdk/adapter/overlay-container-adapter.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/framework/theme/components/cdk/adapter/overlay-container-adapter.ts b/src/framework/theme/components/cdk/adapter/overlay-container-adapter.ts index 0ad4eba0d7..2ae73837db 100644 --- a/src/framework/theme/components/cdk/adapter/overlay-container-adapter.ts +++ b/src/framework/theme/components/cdk/adapter/overlay-container-adapter.ts @@ -2,6 +2,10 @@ import { Injectable } from '@angular/core'; import { NbOverlayContainer } from '../overlay/mapping'; +function throwLayoutNotFoundError(): void { + throw new Error(`[NbOverlayContainerAdapter]: Layout not found. + When using Nebular '' is required and should wrap other nebular components.`); +} /** * Provides nb-layout as overlay container. @@ -24,10 +28,17 @@ export class NbOverlayContainerAdapter extends NbOverlayContainer { } protected _createContainer(): void { - const container = this._document.createElement('div'); + this.checkContainer(); + const container = this._document.createElement('div'); container.classList.add('cdk-overlay-container'); this.container.appendChild(container); this._containerElement = container; } + + protected checkContainer(): void { + if (!this.container) { + throwLayoutNotFoundError(); + } + } }