Skip to content

feat(overlay-directives): support setting panelClass #12380

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

Merged
merged 3 commits into from
Aug 27, 2018
Merged
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions src/cdk/overlay/overlay-directives.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,15 @@ describe('Overlay directives', () => {
expect(backdrop.classList).toContain('mat-test-class');
});

it('should set the custom panel class', () => {
fixture.componentInstance.isOpen = true;
fixture.detectChanges();

const panel
= overlayContainerElement.querySelector('.cdk-overlay-pane') as HTMLElement;
expect(panel.classList).toContain('cdk-test-panel-class');
});

it('should set the offsetX', () => {
fixture.componentInstance.offsetX = 5;
fixture.componentInstance.isOpen = true;
Expand Down Expand Up @@ -480,6 +489,7 @@ describe('Overlay directives', () => {
[cdkConnectedOverlayGrowAfterOpen]="growAfterOpen"
[cdkConnectedOverlayPush]="push"
cdkConnectedOverlayBackdropClass="mat-test-class"
cdkConnectedOverlayPanelClass="cdk-test-panel-class"
(backdropClick)="backdropClickHandler($event)"
[cdkConnectedOverlayOffsetX]="offsetX"
[cdkConnectedOverlayOffsetY]="offsetY"
Expand Down
7 changes: 7 additions & 0 deletions src/cdk/overlay/overlay-directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ export class CdkConnectedOverlay implements OnDestroy, OnChanges {
/** The custom class to be set on the backdrop element. */
@Input('cdkConnectedOverlayBackdropClass') backdropClass: string;

/** The custom class to add to the overlay pane element. */
@Input('cdkConnectedOverlayPanelClass') panelClass: string | string[];

/** Margin between the overlay and the viewport edges. */
@Input('cdkConnectedOverlayViewportMargin') viewportMargin: number = 0;

Expand Down Expand Up @@ -296,6 +299,10 @@ export class CdkConnectedOverlay implements OnDestroy, OnChanges {
overlayConfig.backdropClass = this.backdropClass;
}

if (this.panelClass) {
overlayConfig.panelClass = this.panelClass;
}

return overlayConfig;
}

Expand Down