From 63f2ef4d7feffbe2407722882b8dff8223189e9a Mon Sep 17 00:00:00 2001 From: nename0 <26363498+nename0@users.noreply.github.com> Date: Tue, 2 Oct 2018 22:37:56 +0200 Subject: [PATCH] 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. --- src/cdk/table/sticky-styler.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cdk/table/sticky-styler.ts b/src/cdk/table/sticky-styler.ts index 763cb0acc0e..f0fca155b40 100644 --- a/src/cdk/table/sticky-styler.ts +++ b/src/cdk/table/sticky-styler.ts @@ -140,6 +140,10 @@ export class StickyStyler { this._addStickyStyle(row, position, stickyHeight); } + if (rowIndex === rows.length - 1) { + // prevent unnecessary reflow from getBoundingClientRect() + return; + } stickyHeight += row.getBoundingClientRect().height; } }