Skip to content

[data grid] Lazy loaded group grid with defaultGroupingExpansionDepth={-1} leaves some groups as skeletons. #22715

@mbiggs-gresham

Description

@mbiggs-gresham

Steps to reproduce

Steps:

  1. Create a DataGrid with a dataSource, treeData, lazyLoading and defaultGroupingExpansionDepth={-1}.
  2. Have a dataset of 5 parents with 2 child rows each (Only 1 level deep) so that 5 groups try to load children on initial render with multiple inflight queries. May require minimal network latency.
  3. Observe not all child group fetches complete leaving some flashing as skeletons. Network requests complete, grid doesn't render them.

Current behavior

Observe not all child group fetches complete leaving some flashing as skeletons.

Expected behavior

All child groups should load.

Context

I've patched useGridDataSourceBase.js locally and it appears to resolve the issue. It's a claude fix however, so may not be correct but hopefully may help.

  Suggested fix
  
  Check the cache before clearing. The clear only needs to happen if we're actually going to make a network round-trip:

     if (parentId && parentId !== GRID_ROOT_GROUP_ID && props.signature !== 'DataGrid') {
       options.fetchRowChildren?.([parentId], [fetchParams], showChildrenLoading);
       return;
     }
  -  options.clearDataSourceState?.();
     const cacheKeys = cacheChunkManager.getCacheKeys(fetchParams);
     const responses = cacheKeys.map(cacheKey => cache.get(cacheKey));
     if (!skipCache && responses.every(response => response !== undefined)) {
       lastRequestId.current += 1;
       apiRef.current.applyStrategyProcessor('dataSourceRootRowsUpdate', { ... });
       if (standardRowsUpdateStrategyActive) apiRef.current.setLoading(false);
       return;
     }
  +  options.clearDataSourceState?.();

Your environment

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Search keywords: lazyLoading defaultGroupingExpansionDepth

Order ID: 45466

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope: data gridChanges related to the data grid.status: waiting for maintainerThese issues haven't been looked at yet by a maintainer.support: premium standardSupport request from a Premium standard plan user. https://mui.com/legal/technical-support-sla.
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions