Skip to content

Commit

Permalink
[data grid] Fix "no rows" overlay not showing with active aggregation (
Browse files Browse the repository at this point in the history
…@KenanYusuf) (#16468)

Co-authored-by: Kenan Yusuf <[email protected]>
  • Loading branch information
github-actions[bot] and KenanYusuf authored Feb 5, 2025
1 parent 7461ffd commit 6f60283
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,10 @@ export const addFooterRows = ({
};

const updateRootGroupFooter = (groupNode: GridGroupNode) => {
const shouldHaveFooter = hasAggregationRule && getAggregationPosition(groupNode) === 'footer';
const shouldHaveFooter =
hasAggregationRule &&
getAggregationPosition(groupNode) === 'footer' &&
groupNode.children.length > 0;

if (shouldHaveFooter) {
const rowId = getAggregationFooterRowIdFromGroupId(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -882,4 +882,23 @@ describe('<DataGridPremium /> - Aggregation', () => {
});
});
});

describe('"no rows" overlay', () => {
it('should display "no rows" overlay and not show aggregation footer when there are no rows', () => {
render(
<Test
rows={[]}
initialState={{
aggregation: { model: { id: 'sum' } },
}}
/>,
);

// Check for "no rows" overlay
expect(screen.queryByText('No rows')).not.to.equal(null);

// Ensure aggregation footer is not present
expect(getColumnValues(0)).to.deep.equal([]);
});
});
});

0 comments on commit 6f60283

Please sign in to comment.