Fix filter with empty field (#11787)
Attempt to fix https://github.com/twentyhq/core-team-issues/issues/899 Could not reproduce but that's the only place in the code where I found that we build filters as such, with values for "in" being equal to select options and not recordIds, as it seems to be the case from the sentries (ex: <img width="174" alt="Capture d’écran 2025-04-29 à 11 13 56" src="https://github.com/user-attachments/assets/a0b62de1-fe23-4394-9f86-a205ee32b56c" /> )
This commit is contained in:
@ -15,6 +15,7 @@ import { useRecordBoardRecordGqlFields } from '@/object-record/record-index/hook
|
||||
import { currentRecordSortsComponentState } from '@/object-record/record-sort/states/currentRecordSortsComponentState';
|
||||
import { useUpsertRecordsInStore } from '@/object-record/record-store/hooks/useUpsertRecordsInStore';
|
||||
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
|
||||
import { isNonEmptyString } from '@sniptt/guards';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
type UseLoadRecordIndexBoardProps = {
|
||||
@ -68,17 +69,33 @@ export const useLoadRecordIndexBoardColumn = ({
|
||||
recordBoardId,
|
||||
});
|
||||
|
||||
const recordIndexKanbanFieldMetadataItem = objectMetadataItem.fields.find(
|
||||
(field) => field.id === boardFieldMetadataId,
|
||||
);
|
||||
let recordIndexKanbanFieldMetadataFilter: { [x: string]: any } = {};
|
||||
|
||||
if (isDefined(boardFieldMetadataId)) {
|
||||
const recordIndexKanbanFieldMetadataItem = objectMetadataItem.fields.find(
|
||||
(field) => field.id === boardFieldMetadataId,
|
||||
);
|
||||
|
||||
if (!isDefined(recordIndexKanbanFieldMetadataItem)) {
|
||||
throw new Error('Record index kanban field metadata item not found');
|
||||
}
|
||||
|
||||
if (!isNonEmptyString(recordIndexKanbanFieldMetadataItem?.name ?? '')) {
|
||||
throw new Error('Record index kanban field metadata item name not found');
|
||||
}
|
||||
|
||||
recordIndexKanbanFieldMetadataFilter = {
|
||||
[recordIndexKanbanFieldMetadataItem.name]: isDefined(
|
||||
recordGroupDefinition?.value,
|
||||
)
|
||||
? { in: [recordGroupDefinition.value] }
|
||||
: { is: 'NULL' },
|
||||
};
|
||||
}
|
||||
|
||||
const filter = {
|
||||
...requestFilters,
|
||||
[recordIndexKanbanFieldMetadataItem?.name ?? '']: isDefined(
|
||||
recordGroupDefinition?.value,
|
||||
)
|
||||
? { in: [recordGroupDefinition?.value] }
|
||||
: { is: 'NULL' },
|
||||
...recordIndexKanbanFieldMetadataFilter,
|
||||
};
|
||||
|
||||
const {
|
||||
|
||||
Reference in New Issue
Block a user