Skip to content

Commit 0899053

Browse files
committed
fix prerender; reverse rtl
1 parent 0fe4246 commit 0899053

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

src/cdk/table/row.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,16 @@ export const _CdkHeaderRowDefBase = mixinHasStickyInput(CdkHeaderRowDefBase);
8585
selector: '[cdkHeaderRowDef]',
8686
inputs: ['columns: cdkHeaderRowDef', 'sticky: cdkHeaderRowDefSticky'],
8787
})
88-
export class CdkHeaderRowDef extends _CdkHeaderRowDefBase implements CanStick {
88+
export class CdkHeaderRowDef extends _CdkHeaderRowDefBase implements CanStick, OnChanges {
8989
constructor(template: TemplateRef<any>, _differs: IterableDiffers) {
9090
super(template, _differs);
9191
}
92+
93+
// Prerender fails to recognize that ngOnChanges in a part of this class through inheritance.
94+
// Explicitly define it so that the method is called as part of the Angular lifecycle.
95+
ngOnChanges(changes: SimpleChanges): void {
96+
super.ngOnChanges(changes);
97+
}
9298
}
9399

94100
// Boilerplate for applying mixins to CdkFooterRowDef.
@@ -104,10 +110,16 @@ export const _CdkFooterRowDefBase = mixinHasStickyInput(CdkFooterRowDefBase);
104110
selector: '[cdkFooterRowDef]',
105111
inputs: ['columns: cdkFooterRowDef', 'sticky: cdkFooterRowDefSticky'],
106112
})
107-
export class CdkFooterRowDef extends _CdkFooterRowDefBase implements CanStick {
113+
export class CdkFooterRowDef extends _CdkFooterRowDefBase implements CanStick, OnChanges {
108114
constructor(template: TemplateRef<any>, _differs: IterableDiffers) {
109115
super(template, _differs);
110116
}
117+
118+
// Prerender fails to recognize that ngOnChanges in a part of this class through inheritance.
119+
// Explicitly define it so that the method is called as part of the Angular lifecycle.
120+
ngOnChanges(changes: SimpleChanges): void {
121+
super.ngOnChanges(changes);
122+
}
111123
}
112124

113125
/**

src/cdk/table/sticky-styler.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,17 @@ export class StickyStyler {
7474
const cellWidths: number[] = this._getCellWidths(rows[0]);
7575
const startPositions = this._getStickyStartColumnPositions(cellWidths, stickyStartStates);
7676
const endPositions = this._getStickyEndColumnPositions(cellWidths, stickyEndStates);
77-
const isLtr = this.direction === 'ltr';
77+
const isRtl = this.direction === 'rtl';
7878

7979
for (let row of rows) {
8080
for (let i = 0; i < numCells; i++) {
8181
const cell = row.children[i] as HTMLElement;
8282
if (stickyStartStates[i]) {
83-
this._addStickyStyle(cell, isLtr ? 'left' : 'right', startPositions[i]);
83+
this._addStickyStyle(cell, isRtl ? 'right' : 'left', startPositions[i]);
8484
}
8585

8686
if (stickyEndStates[i]) {
87-
this._addStickyStyle(cell, isLtr ? 'right' : 'left', endPositions[i]);
87+
this._addStickyStyle(cell, isRtl ? 'left' : 'right', endPositions[i]);
8888
}
8989
}
9090
}

0 commit comments

Comments
 (0)