Fix Hide empty groups in List view when Group By is enabled (#16752)

Fixed inconsistency where List view (Group By) still showed empty groups
while Kanban hides them.
Update `visibleRecordGroupIdsComponentFamilySelector` now filters out
groups with zero records using
`recordIndexRecordIdsByGroupComponentFamilyState` and
`recordIndexShouldHideEmptyRecordGroupsComponentState`, ensuring empty
groups are consistently hidden across views.

Fixes #16212
This commit is contained in:
Rajdeep Das
2025-12-24 20:31:57 +05:30
committed by GitHub
parent 5d6c39ec7e
commit dc1bf8dac9
@@ -4,6 +4,8 @@ import { type RecordGroupDefinition } from '@/object-record/record-group/types/R
import { RecordGroupSort } from '@/object-record/record-group/types/RecordGroupSort';
import { recordGroupSortedInsert } from '@/object-record/record-group/utils/recordGroupSortedInsert';
import { recordIndexRecordGroupSortComponentState } from '@/object-record/record-index/states/recordIndexRecordGroupSortComponentState';
import { recordIndexRecordIdsByGroupComponentFamilyState } from '@/object-record/record-index/states/recordIndexRecordIdsByGroupComponentFamilyState';
import { recordIndexShouldHideEmptyRecordGroupsComponentState } from '@/object-record/record-index/states/recordIndexShouldHideEmptyRecordGroupsComponentState';
import { createComponentFamilySelector } from '@/ui/utilities/state/component-state/utils/createComponentFamilySelector';
import { ViewComponentInstanceContext } from '@/views/states/contexts/ViewComponentInstanceContext';
@@ -30,6 +32,12 @@ export const visibleRecordGroupIdsComponentFamilySelector =
}),
);
const shouldHideEmptyRecordGroups = get(
recordIndexShouldHideEmptyRecordGroupsComponentState.atomFamily({
instanceId,
}),
);
const result: RecordGroupDefinition[] = [];
const comparator = (
@@ -60,6 +68,18 @@ export const visibleRecordGroupIdsComponentFamilySelector =
continue;
}
if (shouldHideEmptyRecordGroups) {
const rowIds = get(
recordIndexRecordIdsByGroupComponentFamilyState.atomFamily({
instanceId,
familyKey: recordGroupId,
}),
);
if (rowIds.length === 0) {
continue;
}
}
recordGroupSortedInsert(result, recordGroupDefinition, comparator);
}