From dc1bf8dac917d6067085d2d0658ef80edf4ca689 Mon Sep 17 00:00:00 2001 From: Rajdeep Das Date: Wed, 24 Dec 2025 20:31:57 +0530 Subject: [PATCH] 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 --- ...leRecordGroupIdsComponentFamilySelector.ts | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/packages/twenty-front/src/modules/object-record/record-group/states/selectors/visibleRecordGroupIdsComponentFamilySelector.ts b/packages/twenty-front/src/modules/object-record/record-group/states/selectors/visibleRecordGroupIdsComponentFamilySelector.ts index 90f72745f5..12eccb6f1f 100644 --- a/packages/twenty-front/src/modules/object-record/record-group/states/selectors/visibleRecordGroupIdsComponentFamilySelector.ts +++ b/packages/twenty-front/src/modules/object-record/record-group/states/selectors/visibleRecordGroupIdsComponentFamilySelector.ts @@ -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); }