Skip to content

Commit

Permalink
pass filterResults in child node
Browse files Browse the repository at this point in the history
  • Loading branch information
k-rajat19 committed Dec 28, 2024
1 parent ae6ba64 commit a55ab95
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ export const filterRowTreeFromGroupingColumns = (
areAncestorsExpanded: boolean,
isParentPassingFilter: boolean,
shouldFilterParent: boolean,
ancestorsResults: GridAggregatedFilterItemApplierResult[],
): number => {
const filterResults: GridAggregatedFilterItemApplierResult = {
passingFilterItems: null,
Expand All @@ -177,9 +178,10 @@ export const filterRowTreeFromGroupingColumns = (

const row = apiRef.current.getRow(node.id);
isRowMatchingFilters(row, shouldApplyItem, filterResults);
const allResults = [...ancestorsResults, filterResults];
isPassingFiltering = passFilterLogic(
[filterResults.passingFilterItems],
[filterResults.passingQuickFilterValues],
allResults.map((result) => result.passingFilterItems),
allResults.map((result) => result.passingQuickFilterValues),
filterModel,
params.apiRef,
filterCache,
Expand All @@ -203,6 +205,7 @@ export const filterRowTreeFromGroupingColumns = (
areAncestorsExpanded && !!node.childrenExpanded,
isPassingFiltering,
allowGroupToFilter,
[...ancestorsResults, filterResults],
);
filteredDescendantCount += childSubTreeSize;
if (childSubTreeSize > 0) {
Expand Down Expand Up @@ -235,7 +238,7 @@ export const filterRowTreeFromGroupingColumns = (
for (let i = 0; i < nodes.length; i += 1) {
const node = nodes[i];
if (node.depth === 0) {
filterTreeNode(node, true, true, false);
filterTreeNode(node, true, true, false, []);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2407,7 +2407,7 @@ describe('<DataGridPremium /> - Row grouping', () => {
);

// Corresponds to rows id 0 because of Cat A, ann id 4 because of Cat 1
expect(getColumnValues(1)).to.deep.equal(['', '0', '', '4']);
expect(getColumnValues(1)).to.deep.equal(['', '0', '1', '2', '', '4']);
});

it('should keep the correct count of the children and descendants in the filter state', () => {
Expand Down

0 comments on commit a55ab95

Please sign in to comment.