From 4f4d9fa76e294910668e55980a51739a78131a8a Mon Sep 17 00:00:00 2001 From: Edward Pastuszenski Date: Tue, 9 Jul 2019 10:04:04 -0700 Subject: [PATCH] Omit invisible columns from horizontallyScrollable ManagedTables' width Summary: Currently, `horizontallyScrollable` logic includes even invisible columns in the width calculation for `horizontallyScrollable` `ManagedTable`s, resulting in large empty spaces when many columns are invisible. Reviewed By: danielbuechele Differential Revision: D16139713 fbshipit-source-id: f653121845fbeac8a29bdb67ad0309add28e526a --- src/ui/components/table/ManagedTable.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ui/components/table/ManagedTable.js b/src/ui/components/table/ManagedTable.js index fae6b4198..d71232aef 100644 --- a/src/ui/components/table/ManagedTable.js +++ b/src/ui/components/table/ManagedTable.js @@ -650,8 +650,14 @@ class ManagedTable extends React.Component< let computedWidth = 0; if (horizontallyScrollable) { - for (const col in columnSizes) { - const width = columnSizes[col]; + for (let index = 0; index < columnOrder.length; index++) { + const col = columnOrder[index]; + + if (!col.visible) { + continue; + } + + const width = columnSizes[col.key]; if (isNaN(width)) { // non-numeric columns with, can't caluclate computedWidth = 0;