The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Fix Hide empty groups in List view when Group By is enabled (#16752)
Rajdeep Dasdc1bf8dac917
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.tsindex 90f72745f54..12eccb6f1f2 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/Rimport { 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);}