Skip to content

[DataGridPro] Remove rows deleted server-side on nested lazy loading revalidation - #23320

Draft
JCQuintas wants to merge 2 commits into
mui:masterfrom
JCQuintas:fix-nested-lazy-loading-row-removal
Draft

[DataGridPro] Remove rows deleted server-side on nested lazy loading revalidation#23320
JCQuintas wants to merge 2 commits into
mui:masterfrom
JCQuintas:fix-nested-lazy-loading-row-removal

Conversation

@JCQuintas

Copy link
Copy Markdown
Member

Fixes #23305

Nested (tree data / row grouping) lazy loading never reconciled rows that the server dropped between two fetches: rows were replaced positionally and skeletons were only ever padded up to the row count, so a shrinking result set left stale rows behind, or skeleton rows that never resolved.

Changes

useGridDataSourceNestedLazyLoader:

  • New trimChildrenToRowCount helper: drops the children past the row count reported by the response, together with their subtrees, and cleans up childrenFromPath. Ids re-added by the current pass keep their tree entry.
  • replaceNestedRows trims after the positional replacement, and keeps a group's serverChildrenCount in sync with the server.
  • New pruneRowsToRowCount covers the paths replaceNestedRows cannot: empty responses, and the in-place update path (same ids at the same positions), which previously returned early and left the extra children untouched.
  • addRootSkeletonRows now also trims root rows when the page row count shrinks. pageRowCount > 0 keeps an unknown or not-yet-known count from wiping loaded rows; a genuine drop to 0 goes through pruneRowsToRowCount.

Tests

Four tests in dataSourceLazyLoader.DataGridPro.test.tsx, all failing before this change:

  • last root row dropped by the server
  • middle root row dropped by the server, including a scroll to the tail to check the remaining skeleton resolves instead of stranding
  • last child of an expanded group dropped by the server
  • the equivalent flat lazy loading case, which already worked, as a control

Repros issue mui#23305: nested (tree data) lazy loading does not prune rows
the server drops on revalidation. Flat control test passes.
…revalidation

Nested (tree data / row grouping) lazy loading only replaced rows positionally and
padded skeletons up to the row count, so a shrinking result set left stale rows and
skeleton rows that never resolved.

Trim a parent's children to the row count reported by the response, in all three
update paths: the positional replacement, the in-place (same ids) update, and empty
responses. Root level rows are also trimmed when the page row count shrinks, and a
group's serverChildrenCount is kept in sync with the server.

Fixes mui#23305
@JCQuintas JCQuintas added type: bug It doesn't behave as expected. scope: data grid Changes related to the data grid. feature: Server integration Better integration with backends, e.g. data source feature: Tree data Related to the data grid Tree data feature plan: Pro Impact at least one Pro user. labels Aug 10, 2026
@JCQuintas JCQuintas self-assigned this Aug 10, 2026
@code-infra-dashboard

Copy link
Copy Markdown

Deploy preview

https://deploy-preview-23320--material-ui-x.netlify.app/
QR code for https://deploy-preview-23320--material-ui-x.netlify.app/

Bundle size

Bundle Parsed size Gzip size
@mui/x-data-grid 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-pro 🔺+1.39KB(+0.26%) 🔺+367B(+0.23%)
@mui/x-data-grid-premium 🔺+1.39KB(+0.19%) 🔺+337B(+0.16%)
@mui/x-charts 0B(0.00%) 0B(0.00%)
@mui/x-charts-pro 0B(0.00%) 0B(0.00%)
@mui/x-charts-premium 0B(0.00%) 0B(0.00%)
@mui/x-date-pickers 0B(0.00%) 0B(0.00%)
@mui/x-date-pickers-pro 0B(0.00%) 0B(0.00%)
@mui/x-tree-view 0B(0.00%) 0B(0.00%)
@mui/x-tree-view-pro 0B(0.00%) 0B(0.00%)
@mui/x-scheduler 0B(0.00%) 0B(0.00%)
@mui/x-scheduler-premium 0B(0.00%) 0B(0.00%)
@mui/x-chat 0B(0.00%) 0B(0.00%)
@mui/x-license 0B(0.00%) 0B(0.00%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: Server integration Better integration with backends, e.g. data source feature: Tree data Related to the data grid Tree data feature plan: Pro Impact at least one Pro user. scope: data grid Changes related to the data grid. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[data grid] Tree data + dataSource lazy loading doesn't remove rows deleted by the server on revalidation.

1 participant