Skip to content

Commit 63f2ef4

Browse files
nename0vivian-hu-zz
authored andcommitted
pref(table): prevent unnecessary reflow with sticky row (#12786)
The offset of a sticky row is calculated by summing up the heights of the previous sticky rows. As the access to the height causes a forced reflow this is now skipped when there is only one row.
1 parent 707a7ee commit 63f2ef4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/cdk/table/sticky-styler.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ export class StickyStyler {
140140
this._addStickyStyle(row, position, stickyHeight);
141141
}
142142

143+
if (rowIndex === rows.length - 1) {
144+
// prevent unnecessary reflow from getBoundingClientRect()
145+
return;
146+
}
143147
stickyHeight += row.getBoundingClientRect().height;
144148
}
145149
}

0 commit comments

Comments
 (0)