Skip to content
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
8 changes: 8 additions & 0 deletions src/cdk-experimental/dialog/dialog.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,14 @@ describe('Dialog', () => {
expect(dialogRef.componentInstance.directionality.value).toBe('rtl');
});

it('should fall back to injecting the global direction if none is passed by the config', () => {
const dialogRef = dialog.openFromComponent(PizzaMsg, {});

viewContainerFixture.detectChanges();

expect(dialogRef.componentInstance.directionality.value).toBe('ltr');
});

it('should close all of the dialogs', fakeAsync(() => {
dialog.openFromComponent(PizzaMsg);
dialog.openFromComponent(PizzaMsg);
Expand Down
3 changes: 2 additions & 1 deletion src/cdk-experimental/dialog/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@ export class Dialog {
.set(this.injector.get(DIALOG_CONTAINER), dialogContainer)
.set(DIALOG_DATA, config.data);

if (!userInjector || !userInjector.get<Directionality | null>(Directionality, null)) {
if (config.direction &&
(!userInjector || !userInjector.get<Directionality | null>(Directionality, null))) {
injectionTokens.set(Directionality, {
value: config.direction,
change: observableOf()
Expand Down
8 changes: 8 additions & 0 deletions src/lib/bottom-sheet/bottom-sheet.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,14 @@ describe('MatBottomSheet', () => {
expect(bottomSheetRef.instance.directionality.value).toBe('rtl');
});

it('should fall back to injecting the global direction if none is passed by the config', () => {
const bottomSheetRef = bottomSheet.open(PizzaMsg, {});

viewContainerFixture.detectChanges();

expect(bottomSheetRef.instance.directionality.value).toBe('ltr');
});

it('should be able to set a custom panel class', () => {
bottomSheet.open(PizzaMsg, {
panelClass: 'custom-panel-class',
Expand Down
3 changes: 2 additions & 1 deletion src/lib/bottom-sheet/bottom-sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ export class MatBottomSheet {
injectionTokens.set(MatBottomSheetRef, bottomSheetRef);
injectionTokens.set(MAT_BOTTOM_SHEET_DATA, config.data);

if (!userInjector || !userInjector.get<Directionality | null>(Directionality, null)) {
if (config.direction &&
(!userInjector || !userInjector.get<Directionality | null>(Directionality, null))) {
injectionTokens.set(Directionality, {
value: config.direction,
change: observableOf()
Expand Down
8 changes: 8 additions & 0 deletions src/lib/dialog/dialog.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,14 @@ describe('MatDialog', () => {
expect(dialogRef.componentInstance.directionality.value).toBe('rtl');
});

it('should fall back to injecting the global direction if none is passed by the config', () => {
const dialogRef = dialog.open(PizzaMsg, {});

viewContainerFixture.detectChanges();

expect(dialogRef.componentInstance.directionality.value).toBe('ltr');
});

it('should close all of the dialogs', fakeAsync(() => {
dialog.open(PizzaMsg);
dialog.open(PizzaMsg);
Expand Down
3 changes: 2 additions & 1 deletion src/lib/dialog/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,8 @@ export class MatDialog {
.set(MAT_DIALOG_DATA, config.data)
.set(MatDialogRef, dialogRef);

if (!userInjector || !userInjector.get<Directionality | null>(Directionality, null)) {
if (config.direction &&
(!userInjector || !userInjector.get<Directionality | null>(Directionality, null))) {
injectionTokens.set(Directionality, {
value: config.direction,
change: observableOf()
Expand Down
8 changes: 4 additions & 4 deletions src/lib/sidenav/drawer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -627,12 +627,12 @@ export class MatDrawerContainer implements AfterContentInit, DoCheck, OnDestroy
this._right = this._left = null;

// Detect if we're LTR or RTL.
if (!this._dir || this._dir.value == 'ltr') {
this._left = this._start;
this._right = this._end;
} else {
if (this._dir && this._dir.value === 'rtl') {
this._left = this._end;
this._right = this._start;
} else {
this._left = this._start;
this._right = this._end;
}
}

Expand Down