Skip to content

Commit

Permalink
Fix: Pivot expansion on infinite scroll (#4482)
Browse files Browse the repository at this point in the history
* Fix: Expansion after infinite row scroll

* Fix expansion order

* Remove log
  • Loading branch information
djbarnwal authored Apr 2, 2024
1 parent 12140b5 commit fed7ebf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
21 changes: 7 additions & 14 deletions web-common/src/features/dashboards/pivot/pivot-data-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ export function createTableCellQuery(
totalsRow: PivotDataRow,
rowDimensionValues: string[],
) {
if (!rowDimensionValues.length) return readable(null);
let allDimensions = config.colDimensionNames;
if (anchorDimension) {
allDimensions = config.colDimensionNames.concat([anchorDimension]);
Expand Down Expand Up @@ -376,8 +377,9 @@ function createPivotDataStore(ctx: StateManagers): PivotDataStore {
);
}

const displayTotalsRow =
rowDimensionNames.length && measureNames.length;
const displayTotalsRow = Boolean(
rowDimensionNames.length && measureNames.length,
);
if (
(rowDimensionNames.length || colDimensionNames.length) &&
measureNames.length
Expand Down Expand Up @@ -430,18 +432,6 @@ function createPivotDataStore(ctx: StateManagers): PivotDataStore {
const rowDimensionValues =
rowDimensionAxes?.data?.[anchorDimension] || [];

if (rowDimensionValues.length === 0 && rowPage > 1) {
return axesSet({
isFetching: false,
data: lastPivotData,
columnDef: lastPivotColumnDef,
assembled: true,
totalColumns: lastTotalColumns,
totalsRowData: displayTotalsRow ? totalsRowData : undefined,
reachedEndForRowData: true,
});
}

const totalColumns = getTotalColumnCount(totalsRowData);

const axesRowTotals =
Expand Down Expand Up @@ -585,12 +575,15 @@ function createPivotDataStore(ctx: StateManagers): PivotDataStore {
lastPivotColumnDef = columnDef;
lastTotalColumns = totalColumns;

const reachedEndForRowData =
rowDimensionValues.length === 0 && rowPage > 1;
return {
isFetching: false,
data: tableDataExpanded,
columnDef,
assembled: true,
totalColumns,
reachedEndForRowData,
totalsRowData: displayTotalsRow
? totalsRowData
: undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ export function addExpandedDataToPivot(
columnDimensionAxes,
skeletonSubTable,
expandedRowData?.data,
true,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ export function reduceTableCellDataIntoRows(
columnDimensionAxes: Record<string, string[]>,
tableData: PivotDataRow[],
cellData: V1MetricsViewAggregationResponseDataItem[],
isExpanded = false,
) {
const colDimensionNames = config.colDimensionNames;
const rowPage = config.pivot.rowPage;
const rowOffset = (rowPage - 1) * NUM_ROWS_PER_PAGE;
const rowOffset = isExpanded ? 0 : (rowPage - 1) * NUM_ROWS_PER_PAGE;

/**
* Create a map of row dimension values to their index in the row dimension axes.
Expand Down

1 comment on commit fed7ebf

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.