components icon indicating copy to clipboard operation
components copied to clipboard

Refactor Data Table column width calculations

Open devDroid opened this issue 1 year ago • 0 comments

In a previous PR I managed to remove some weird behaviour on the Data Table which caused any "control" column (row expansion or row selection) to inherit the width of a different column, which was usually way more than what the chevron icon for row expansion, or the checkbox for row selection needed.

However, I achieved the desired effect in a very imperative way. I since realised that perhaps passing a correct and distinctive "key" prop to the scroll container which controlled the sticky column behaviour would achieve the same result, but without explicit calculations.

With this PR I remove all the maths and just pass down a "controlColumnCount" prop from the top-level DataTable.Table component to the "Table" component. This value is then used to build a unique key on the scroll container, to ensure it rerenders once we have an extra column in the table (which is not a data table, since it's just an extra cell we're adding ad-hoc to each row).

devDroid avatar Jul 04 '24 12:07 devDroid