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) => {