@@ -6,6 +6,7 @@ import {CommonModule} from '@angular/common';
6
6
import { Component , ElementRef , Type , ViewChild } from '@angular/core' ;
7
7
import { ComponentFixture , fakeAsync , flush , TestBed , tick } from '@angular/core/testing' ;
8
8
import { FormsModule , NgForm } from '@angular/forms' ;
9
+ import { BidiModule , Direction } from '@angular/cdk/bidi' ;
9
10
import { BehaviorSubject } from 'rxjs' ;
10
11
11
12
import { CdkPopoverEditColspan , CdkPopoverEditModule , PopoverEditClickOutBehavior } from './index' ;
@@ -61,6 +62,7 @@ abstract class BaseTestComponent {
61
62
ignoreSubmitUnlessValid = true ;
62
63
clickOutBehavior : PopoverEditClickOutBehavior = 'close' ;
63
64
colspan : CdkPopoverEditColspan = { } ;
65
+ direction : Direction = 'ltr' ;
64
66
65
67
onSubmit ( element : PeriodicElement , form : NgForm ) {
66
68
if ( ! form . valid ) { return ; }
@@ -147,7 +149,7 @@ abstract class BaseTestComponent {
147
149
148
150
@Component ( {
149
151
template : `
150
- <table #table editable>
152
+ <table #table editable [dir]="direction" >
151
153
<ng-template #nameEdit let-element>
152
154
${ NAME_EDIT_TEMPLATE }
153
155
</ng-template>
@@ -177,7 +179,7 @@ class VanillaTableOutOfCell extends BaseTestComponent {
177
179
178
180
@Component ( {
179
181
template : `
180
- <table #table editable>
182
+ <table #table editable [dir]="direction" >
181
183
<tr *ngFor="let element of elements">
182
184
<td> just a cell </td>
183
185
@@ -218,7 +220,7 @@ class ElementDataSource extends DataSource<PeriodicElement> {
218
220
219
221
@Component ( {
220
222
template : `
221
- <div #table>
223
+ <div #table [dir]="direction" >
222
224
<cdk-table cdk-table editable [dataSource]="dataSource">
223
225
<ng-container cdkColumnDef="before">
224
226
<cdk-cell *cdkCellDef="let element">
@@ -264,7 +266,7 @@ class CdkFlexTableInCell extends BaseTestComponent {
264
266
265
267
@Component ( {
266
268
template : `
267
- <div #table>
269
+ <div #table [dir]="direction" >
268
270
<table cdk-table editable [dataSource]="dataSource">
269
271
<ng-container cdkColumnDef="before">
270
272
<td cdk-cell *cdkCellDef="let element">
@@ -323,7 +325,7 @@ describe('CDK Popover Edit', () => {
323
325
324
326
beforeEach ( ( ) => {
325
327
TestBed . configureTestingModule ( {
326
- imports : [ CdkTableModule , CdkPopoverEditModule , CommonModule , FormsModule ] ,
328
+ imports : [ CdkTableModule , CdkPopoverEditModule , CommonModule , FormsModule , BidiModule ] ,
327
329
declarations : [ componentClass ] ,
328
330
} ) . compileComponents ( ) ;
329
331
fixture = TestBed . createComponent ( componentClass ) ;
@@ -720,6 +722,16 @@ cdkPopoverEditTabOut`, fakeAsync(() => {
720
722
721
723
expect ( document . activeElement ) . toBe ( component . getEditCell ( 1 ) ) ;
722
724
} ) ) ;
725
+
726
+ it ( 'should pass the directionality to the overlay' , fakeAsync ( ( ) => {
727
+ component . direction = 'rtl' ;
728
+ fixture . detectChanges ( ) ;
729
+
730
+ component . openLens ( ) ;
731
+
732
+ expect ( component . getEditBoundingBox ( ) ! . getAttribute ( 'dir' ) ) . toBe ( 'rtl' ) ;
733
+ } ) ) ;
734
+
723
735
} ) ;
724
736
} ) ;
725
737
}
0 commit comments