feat(overlay): support setting panelClass on cdkConnectedOverlay (#12380)

This commit is contained in:
Jian Liao
2018-08-27 09:59:47 -07:00
committed by Jeremy Elbourn
parent 3b7f0f12d4
commit d7c734c101
2 changed files with 17 additions and 0 deletions
@@ -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;
@@ -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"
+7
View File
@@ -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;
@@ -296,6 +299,10 @@ export class CdkConnectedOverlay implements OnDestroy, OnChanges {
overlayConfig.backdropClass = this.backdropClass;
}
if (this.panelClass) {
overlayConfig.panelClass = this.panelClass;
}
return overlayConfig;
}