Skip to content

Commit

Permalink
Check for skeleton rows with the sorting and filtering enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
arminmeh committed Aug 2, 2024
1 parent fe1b106 commit 951a895
Showing 1 changed file with 19 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,28 +65,27 @@ export const useGridDataSourceLazyLoader = (
lastRowToRender: params.lastRowIndex,
};

if (sortModel.length === 0 && filterModel.items.length === 0) {
const currentVisibleRows = getVisibleRows(privateApiRef, {
pagination: props.pagination,
paginationMode: props.paginationMode,
});
const skeletonRowsSection = findSkeletonRowsSection({
apiRef: privateApiRef,
visibleRows: currentVisibleRows.rows,
range: {
firstRowIndex: params.firstRowIndex,
lastRowIndex: params.lastRowIndex,
},
});

if (!skeletonRowsSection) {
return;
}

fetchRowsParams.start = skeletonRowsSection.firstRowIndex;
fetchRowsParams.end = skeletonRowsSection.lastRowIndex;
const currentVisibleRows = getVisibleRows(privateApiRef, {
pagination: props.pagination,
paginationMode: props.paginationMode,
});

const skeletonRowsSection = findSkeletonRowsSection({
apiRef: privateApiRef,
visibleRows: currentVisibleRows.rows,
range: {
firstRowIndex: params.firstRowIndex,
lastRowIndex: params.lastRowIndex,
},
});

if (!skeletonRowsSection) {
return;
}

fetchRowsParams.start = skeletonRowsSection.firstRowIndex;
fetchRowsParams.end = skeletonRowsSection.lastRowIndex;

privateApiRef.current.publishEvent('getRows', fetchRowsParams);
},
[privateApiRef, isDisabled, props.pagination, props.paginationMode, sortModel, filterModel],
Expand Down Expand Up @@ -141,7 +140,6 @@ export const useGridDataSourceLazyLoader = (
'renderedRowsIntervalChange',
handleRenderedRowsIntervalChange,
);
// TODO: if sorting/filtering happens firther away from the top, sometimes one skeleton row is left
useGridApiEventHandler(privateApiRef, 'sortModelChange', handleGridSortModelChange);
useGridApiEventHandler(privateApiRef, 'filterModelChange', handleGridFilterModelChange);
};

0 comments on commit 951a895

Please sign in to comment.