From 9ab3f19d90a628fcbc87a45b0b3e799e3350ea2e Mon Sep 17 00:00:00 2001 From: Brian Ingles Date: Thu, 2 Mar 2023 15:44:56 -0600 Subject: [PATCH] Better fix that isn't dependent on array order [#1062] --- packages/iris-grid/src/IrisGridRenderer.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/iris-grid/src/IrisGridRenderer.ts b/packages/iris-grid/src/IrisGridRenderer.ts index 4c5b865a93..00d5ddc6c7 100644 --- a/packages/iris-grid/src/IrisGridRenderer.ts +++ b/packages/iris-grid/src/IrisGridRenderer.ts @@ -187,14 +187,14 @@ class IrisGridRenderer extends GridRenderer { return; } - // The `groupedColumns` array contains 2 items for each grouped column name. - // The first half of the array contains 1 copy of each column in display order. - // The second half is not sorted in display order. To get the last displayed - // group column, we can use the last column in the first half of the array. - const modelIndex = groupedColumns.length / 2 - 1; - - const columnX = allColumnXs.get(modelIndex); - const columnWidth = allColumnWidths.get(modelIndex); + // There seem to be duplicate columns with the same name, so determine the + // count of distinct names. + const numUniqueNames = new Set(groupedColumns.map(({ name }) => name)).size; + + const lastVisibleGroupColumnIndex = numUniqueNames - 1; + + const columnX = allColumnXs.get(lastVisibleGroupColumnIndex); + const columnWidth = allColumnWidths.get(lastVisibleGroupColumnIndex); if (columnX == null || columnWidth == null) { return; }