Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(layout): added error message if layout not provided #2778

Merged
merged 3 commits into from
Aug 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}
}
}