Skip to content

[data grid] Stop the lazy loading polling when lazyLoading turns off - #23717

Merged
LukasTy merged 3 commits into
mui:masterfrom
LukasTy:claude/beautiful-chandrasekhar-904361
Oct 1, 2026
Merged

LukasTy merged 3 commits into
mui:masterfrom
LukasTy:claude/beautiful-chandrasekhar-904361

Conversation

@LukasTy

@LukasTy LukasTy commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #23714.

When lazyLoading turns off, the active strategy becomes Default, but the flat lazy loader does not stop its polling. Its interval continues to call revalidate(params) with the old lazy range, and the Default strategy applies each response with setRows(). The visible rows then alternate between the current page and the old lazy range.

useGridDataSourceBase and the nested lazy loader already stop the polling when their strategy turns inactive. The flat lazy loader stops it only when dataSourceRevalidateMs is 0 or less.

  • useGridDataSourcePolling now stops the polling when isActive is false or revalidateMs is 0 or less.

  • This effect replaces the stop effects in useGridDataSourceBase (two) and in each lazy loader (one).

  • A new test turns off lazyLoading while the flat lazy loader polls. The test fails without the fix.

  • I have followed (at least) the PR section of the contributing guide.

Generated with Claude Code

LukasTy and others added 2 commits September 30, 2026 11:15
`useGridDataSourceBase` and the two lazy loaders repeated the same
polling setup. `useGridDataSourcePolling` now owns the interval and the
flag that blocks a restart after unmount or while an `<Activity>` is
hidden. It also resumes the polling when the `<Activity>` shows the
grid again.

The queued sort fetch test now waits for the row id. The old check
passed on `undefined` before the grid mounted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When `lazyLoading` turned off, the flat lazy loader continued to poll the
old lazy range. The `Default` strategy applied those responses, so the rows
alternated between the current page and the old range.

`useGridDataSourcePolling` now stops the polling when `isActive` is `false`
or `revalidateMs` is `0` or less. This effect replaces the stop effects in
`useGridDataSourceBase` and in the two lazy loaders.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@LukasTy LukasTy added type: bug It doesn't behave as expected. scope: data grid Changes related to the data grid. labels Sep 30, 2026
@code-infra-dashboard

code-infra-dashboard Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Deploy preview

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

Bundle size

Bundle Parsed size Gzip size
@mui/x-data-grid ▼-27B(-0.01%) ▼-10B(-0.01%)
@mui/x-data-grid-pro ▼-194B(-0.04%) ▼-50B(-0.03%)
@mui/x-data-grid-premium ▼-195B(-0.03%) ▼-50B(-0.02%)
@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.

@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Sep 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

…chandrasekhar-904361

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Sep 30, 2026
@LukasTy
LukasTy requested a balanced review from Copilot September 30, 2026 13:56
@LukasTy
LukasTy marked this pull request as ready for review September 30, 2026 13:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The centralized fix matches existing behavior and the regression test covers the reported failure.

Review effort: Balanced
Findings: None

What changed in this PR

Centralizes polling shutdown logic so inactive data-source strategies cannot continue stale revalidation.

Changes:

  • Stops polling when isActive is false or the interval is non-positive.
  • Removes redundant caller-level shutdown effects.
  • Adds a regression test for disabling flat lazy loading during polling.
File Description
packages/​x-data-grid/​src/​hooks/​features/​dataSource/​useGridDataSourcePolling.ts Centralizes polling shutdown.
packages/​x-data-grid/​src/​hooks/​features/​dataSource/​useGridDataSourceBase.ts Removes redundant effects.
packages/​x-data-grid-pro/​src/​tests/​dataSourceLazyLoader.DataGridPro.test.tsx Tests disabling lazy loading.
packages/​x-data-grid-pro/​src/​hooks/​features/​serverSideLazyLoader/​useGridDataSourceNestedLazyLoader.ts Uses centralized shutdown.
packages/​x-data-grid-pro/​src/​hooks/​features/​serverSideLazyLoader/​useGridDataSourceLazyLoader.ts Uses centralized shutdown.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@LukasTy LukasTy self-assigned this Sep 30, 2026
@LukasTy LukasTy added the feature: Server integration Better integration with backends, e.g. data source label Sep 30, 2026
@LukasTy
LukasTy merged commit 1b5d015 into mui:master Oct 1, 2026
25 checks passed
@LukasTy
LukasTy deleted the claude/beautiful-chandrasekhar-904361 branch October 1, 2026 06:25
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 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.

3 participants