Skip to content

Commit

Permalink
Better fix that isn't dependent on array order
Browse files Browse the repository at this point in the history
  • Loading branch information
bmingles committed Mar 3, 2023
1 parent 68ac553 commit 9ab3f19
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions packages/iris-grid/src/IrisGridRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 9ab3f19

Please sign in to comment.