Skip to content

Commit 4658c85

Browse files
crisbetoandrewseguin
authored andcommitted
feat(dialog): allow setting the layout direction (#4778)
Allows users to set the layout direction of a dialog.
1 parent 4fcab57 commit 4658c85

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

src/lib/dialog/dialog-config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {ViewContainerRef} from '@angular/core';
2+
import {LayoutDirection} from '../core';
23

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

55+
/** Layout direction for the dialog's content. */
56+
direction?: LayoutDirection = 'ltr';
57+
5458
// TODO(jelbourn): add configuration for lifecycle hooks, ARIA labelling.
5559
}

src/lib/dialog/dialog.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,16 @@ describe('MdDialog', () => {
312312
expect(overlayPane.style.width).toBe('200px');
313313
});
314314

315+
it('should allow setting the layout direction', () => {
316+
let dialogRef = dialog.open(PizzaMsg, { direction: 'rtl' });
317+
318+
viewContainerFixture.detectChanges();
319+
320+
let overlayPane = overlayContainerElement.querySelector('.cdk-overlay-pane');
321+
322+
expect(overlayPane.getAttribute('dir')).toBe('rtl');
323+
});
324+
315325
it('should close all of the dialogs', async(() => {
316326
dialog.open(PizzaMsg);
317327
dialog.open(PizzaMsg);

src/lib/dialog/dialog.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ export class MdDialog {
127127
overlayState.panelClass = dialogConfig.panelClass;
128128
overlayState.hasBackdrop = dialogConfig.hasBackdrop;
129129
overlayState.scrollStrategy = this._overlay.scrollStrategies.block();
130+
overlayState.direction = dialogConfig.direction;
130131
if (dialogConfig.backdropClass) {
131132
overlayState.backdropClass = dialogConfig.backdropClass;
132133
}

0 commit comments

Comments
 (0)