Skip to content

Commit

Permalink
feat(layout): added error message if layout not provided (#2778)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreipadolin authored Aug 4, 2021
1 parent ff00a16 commit 7c12874
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<nb-layout>' is required and should wrap other nebular components.`);
}

/**
* Provides nb-layout as overlay container.
Expand All @@ -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();
}
}
}

0 comments on commit 7c12874

Please sign in to comment.