Skip to content

Commit

Permalink
feat(overlay): support setting panelClass on cdkConnectedOverlay (#12380
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jianliao authored and jelbourn committed Aug 27, 2018
1 parent 3b7f0f1 commit d7c734c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
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 @@ -232,6 +232,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 @@ -478,6 +487,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

0 comments on commit d7c734c

Please sign in to comment.