Skip to content

Commit

Permalink
fix: GridMetrics including totals rows in visible rows when scrolled …
Browse files Browse the repository at this point in the history
…to bottom (#2194)

Noticed this while working on databars. The totals rows are being
included in `metrics.visibleRows` when scrolled to the bottom. They were
also being duplicated in `allRows`.

1. Create a table such as `t = empty_table(1000).update(["X=ii"])`
2. Add an aggregation
3. Scroll to bottom of the table
4. Log `visibleRows` or `allRows` from `GridMetrics`

Without this change you'll see that the totals row(s) (index 1000+) are
included in those arrays when scrolled to the bottom. They are doubled
in `allRows`

This doesn't seem to be the issue when aggregations are set to the top
and the table is scrolled to the top.
  • Loading branch information
mattrunyon committed Aug 20, 2024
1 parent 0b37477 commit d409e96
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/grid/src/GridMetricCalculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -974,8 +974,8 @@ export class GridMetricCalculator {
let y = 0;
let row = top;
const rowHeights = new Map();
const { rowCount } = model;
while (y < height + topOffset && row < rowCount) {
const { rowCount, floatingBottomRowCount } = model;
while (y < height + topOffset && row < rowCount - floatingBottomRowCount) {
const rowHeight = this.getVisibleRowHeight(row, state);
rowHeights.set(row, rowHeight);
y += rowHeight;
Expand Down Expand Up @@ -1039,8 +1039,11 @@ export class GridMetricCalculator {
let x = 0;
let column = left;
const columnWidths = new Map();
const { columnCount } = model;
while (x < width + leftOffset && column < columnCount) {
const { columnCount, floatingRightColumnCount } = model;
while (
x < width + leftOffset &&
column < columnCount - floatingRightColumnCount
) {
const columnWidth = this.getVisibleColumnWidth(
column,
state,
Expand Down

0 comments on commit d409e96

Please sign in to comment.