@@ -24,6 +24,7 @@ import {
24
24
getTableUnknownColumnError ,
25
25
getTableUnknownDataSourceError
26
26
} from './table-errors' ;
27
+ import { BidiModule } from '@angular/cdk/bidi' ;
27
28
28
29
describe ( 'CdkTable' , ( ) => {
29
30
let fixture : ComponentFixture < any > ;
@@ -33,7 +34,7 @@ describe('CdkTable', () => {
33
34
function createComponent < T > ( componentType : Type < T > , declarations : any [ ] = [ ] ) :
34
35
ComponentFixture < T > {
35
36
TestBed . configureTestingModule ( {
36
- imports : [ CdkTableModule ] ,
37
+ imports : [ CdkTableModule , BidiModule ] ,
37
38
declarations : [ componentType , ...declarations ] ,
38
39
} ) . compileComponents ( ) ;
39
40
@@ -831,6 +832,36 @@ describe('CdkTable', () => {
831
832
footerRows . forEach ( row => expectNoStickyStyles ( getFooterCells ( row ) ) ) ;
832
833
} ) ;
833
834
835
+ it ( 'should reverse directions for sticky columns in rtl' , ( ) => {
836
+ component . dir = 'rtl' ;
837
+ component . stickyStartColumns = [ 'column-1' , 'column-2' ] ;
838
+ component . stickyEndColumns = [ 'column-5' , 'column-6' ] ;
839
+ fixture . detectChanges ( ) ;
840
+
841
+ const firstColumnWidth = getHeaderCells ( headerRows [ 0 ] ) [ 0 ] . getBoundingClientRect ( ) . width ;
842
+ const lastColumnWidth = getHeaderCells ( headerRows [ 0 ] ) [ 5 ] . getBoundingClientRect ( ) . width ;
843
+
844
+ let headerCells = getHeaderCells ( headerRows [ 0 ] ) ;
845
+ expectStickyStyles ( headerCells [ 0 ] , '1' , { right : '0px' } ) ;
846
+ expectStickyStyles ( headerCells [ 1 ] , '1' , { right : `${ firstColumnWidth } px` } ) ;
847
+ expectStickyStyles ( headerCells [ 4 ] , '1' , { left : `${ lastColumnWidth } px` } ) ;
848
+ expectStickyStyles ( headerCells [ 5 ] , '1' , { left : '0px' } ) ;
849
+
850
+ dataRows . forEach ( row => {
851
+ let cells = getCells ( row ) ;
852
+ expectStickyStyles ( cells [ 0 ] , '1' , { right : '0px' } ) ;
853
+ expectStickyStyles ( cells [ 1 ] , '1' , { right : `${ firstColumnWidth } px` } ) ;
854
+ expectStickyStyles ( cells [ 4 ] , '1' , { left : `${ lastColumnWidth } px` } ) ;
855
+ expectStickyStyles ( cells [ 5 ] , '1' , { left : '0px' } ) ;
856
+ } ) ;
857
+
858
+ let footerCells = getFooterCells ( footerRows [ 0 ] ) ;
859
+ expectStickyStyles ( footerCells [ 0 ] , '1' , { right : '0px' } ) ;
860
+ expectStickyStyles ( footerCells [ 1 ] , '1' , { right : `${ firstColumnWidth } px` } ) ;
861
+ expectStickyStyles ( footerCells [ 4 ] , '1' , { left : `${ lastColumnWidth } px` } ) ;
862
+ expectStickyStyles ( footerCells [ 5 ] , '1' , { left : '0px' } ) ;
863
+ } ) ;
864
+
834
865
it ( 'should stick and unstick combination of sticky header, footer, and columns' , ( ) => {
835
866
component . stickyHeaders = [ 'header-1' ] ;
836
867
component . stickyFooters = [ 'footer-3' ] ;
@@ -1710,7 +1741,7 @@ class TrackByCdkTableApp {
1710
1741
1711
1742
@Component ( {
1712
1743
template : `
1713
- <cdk-table [dataSource]="dataSource">
1744
+ <cdk-table [dataSource]="dataSource" [dir]="dir" >
1714
1745
<ng-container [cdkColumnDef]="column" *ngFor="let column of columns"
1715
1746
[sticky]="isStuck(stickyStartColumns, column)"
1716
1747
[stickyEnd]="isStuck(stickyEndColumns, column)">
@@ -1749,6 +1780,7 @@ class StickyFlexLayoutCdkTableApp {
1749
1780
1750
1781
@ViewChild ( CdkTable ) table : CdkTable < TestData > ;
1751
1782
1783
+ dir = 'ltr' ;
1752
1784
stickyHeaders : string [ ] = [ ] ;
1753
1785
stickyFooters : string [ ] = [ ] ;
1754
1786
stickyStartColumns : string [ ] = [ ] ;
0 commit comments