From 103d1fc06456b1809f805639c7d1efd5f15a9699 Mon Sep 17 00:00:00 2001 From: Adi Dahiya Date: Thu, 3 Mar 2022 16:51:06 +0000 Subject: [PATCH] [v4] [table] fix(Table2): more column resizing issues --- packages/table/src/common/utils.ts | 17 +++++++++++++++++ packages/table/src/table2.tsx | 21 +++++++++------------ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/packages/table/src/common/utils.ts b/packages/table/src/common/utils.ts index a913ad4a86..688955a7eb 100644 --- a/packages/table/src/common/utils.ts +++ b/packages/table/src/common/utils.ts @@ -347,6 +347,23 @@ export const Utils = { const approxCellHeight = approxNumLinesDesired * approxLineHeight; return approxCellHeight; }, + + /** + * Shallow comparison of potentially sparse arrays. + * + * @returns true if the array values are equal + */ + compareSparseArrays( + a: Array | undefined, + b: Array | undefined, + ): boolean { + return ( + a !== undefined && + b !== undefined && + a.length === b.length && + a.every((aValue, index) => aValue === b[index]) + ); + }, }; // table is nearly deprecated, let's not block on code coverage diff --git a/packages/table/src/table2.tsx b/packages/table/src/table2.tsx index 6a08a9d1e9..b42e80176b 100644 --- a/packages/table/src/table2.tsx +++ b/packages/table/src/table2.tsx @@ -258,6 +258,7 @@ export class Table2 extends AbstractComponent2 { @@ -1236,11 +1237,7 @@ export class Table2 extends AbstractComponent2) => {