Skip to content

Commit

Permalink
feat(dialog): allow setting the layout direction (#4778)
Browse files Browse the repository at this point in the history
Allows users to set the layout direction of a dialog.
  • Loading branch information
crisbeto authored and andrewseguin committed Jun 7, 2017
1 parent 4fcab57 commit 4658c85
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/lib/dialog/dialog-config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {ViewContainerRef} from '@angular/core';
import {LayoutDirection} from '../core';

/** Valid ARIA roles for a dialog element. */
export type DialogRole = 'dialog' | 'alertdialog';
Expand Down Expand Up @@ -51,5 +52,8 @@ export class MdDialogConfig {
/** Data being injected into the child component. */
data?: any = null;

/** Layout direction for the dialog's content. */
direction?: LayoutDirection = 'ltr';

// TODO(jelbourn): add configuration for lifecycle hooks, ARIA labelling.
}
10 changes: 10 additions & 0 deletions src/lib/dialog/dialog.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,16 @@ describe('MdDialog', () => {
expect(overlayPane.style.width).toBe('200px');
});

it('should allow setting the layout direction', () => {
let dialogRef = dialog.open(PizzaMsg, { direction: 'rtl' });

viewContainerFixture.detectChanges();

let overlayPane = overlayContainerElement.querySelector('.cdk-overlay-pane');

expect(overlayPane.getAttribute('dir')).toBe('rtl');
});

it('should close all of the dialogs', async(() => {
dialog.open(PizzaMsg);
dialog.open(PizzaMsg);
Expand Down
1 change: 1 addition & 0 deletions src/lib/dialog/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export class MdDialog {
overlayState.panelClass = dialogConfig.panelClass;
overlayState.hasBackdrop = dialogConfig.hasBackdrop;
overlayState.scrollStrategy = this._overlay.scrollStrategies.block();
overlayState.direction = dialogConfig.direction;
if (dialogConfig.backdropClass) {
overlayState.backdropClass = dialogConfig.backdropClass;
}
Expand Down

0 comments on commit 4658c85

Please sign in to comment.