Skip to content

Commit a732029

Browse files
araj00FelixMalfait
authored andcommitted
Fix the default value of search record if the filter is boolean type (twentyhq#17297)
This fixes the twentyhq#15896. For problem statement. Please refer to the shared video mentioned in the issue. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Aligns filter defaults across UI by centralizing initial value computation. > > - Add boolean handling in `useGetInitialFilterValue` to return `value/displayValue` of `'false'` when operand is `IS` > - Update `WorkflowDropdownStepOutputItems` to use `getInitialFilterValue` for initial `value` instead of an empty string, based on field type and default operand > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 3ce05fa. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Félix Malfait <felix.malfait@gmail.com> Co-authored-by: Félix Malfait <felix@twenty.com>
1 parent f0d0a1a commit a732029

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

packages/twenty-front/src/modules/object-record/object-filter-dropdown/hooks/useGetInitialFilterValue.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ export const useGetInitialFilterValue = () => {
5555
return { value: '', displayValue: '' };
5656
}
5757

58+
break;
59+
}
60+
case 'BOOLEAN': {
61+
if (newOperand === RecordFilterOperand.IS) {
62+
return { value: 'false', displayValue: 'false' };
63+
}
64+
5865
break;
5966
}
6067
}

packages/twenty-front/src/modules/workflow/workflow-steps/components/WorkflowDropdownStepOutputItems.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { DropdownMenuSeparator } from '@/ui/layout/dropdown/components/DropdownM
55

66
import { useGetFieldMetadataItemByIdOrThrow } from '@/object-metadata/hooks/useGetFieldMetadataItemById';
77
import { useObjectMetadataItems } from '@/object-metadata/hooks/useObjectMetadataItems';
8+
import { useGetInitialFilterValue } from '@/object-record/object-filter-dropdown/hooks/useGetInitialFilterValue';
89
import { DropdownContent } from '@/ui/layout/dropdown/components/DropdownContent';
910
import { DropdownMenuHeaderLeftComponent } from '@/ui/layout/dropdown/components/DropdownMenuHeader/internal/DropdownMenuHeaderLeftComponent';
1011
import { GenericDropdownContentWidth } from '@/ui/layout/dropdown/constants/GenericDropdownContentWidth';
@@ -22,7 +23,10 @@ import { getVariableTemplateFromPath } from '@/workflow/workflow-variables/utils
2223
import { searchVariableThroughOutputSchemaV2 } from '@/workflow/workflow-variables/utils/searchVariableThroughOutputSchemaV2';
2324
import { useLingui } from '@lingui/react/macro';
2425
import { useRecoilCallback } from 'recoil';
25-
import { type StepFilter } from 'twenty-shared/types';
26+
import {
27+
type FilterableAndTSVectorFieldType,
28+
type StepFilter,
29+
} from 'twenty-shared/types';
2630
import { isDefined } from 'twenty-shared/utils';
2731
import { extractRawVariableNamePart } from 'twenty-shared/workflow';
2832
import {
@@ -55,6 +59,8 @@ export const WorkflowDropdownStepOutputItems = ({
5559
const workflowVersionId = useWorkflowVersionIdOrThrow();
5660
const { objectMetadataItems } = useObjectMetadataItems();
5761

62+
const { getInitialFilterValue } = useGetInitialFilterValue();
63+
5864
const updateStepFilter = useRecoilCallback(
5965
({ snapshot }) =>
6066
({
@@ -101,13 +107,18 @@ export const WorkflowDropdownStepOutputItems = ({
101107
});
102108
const defaultOperand = availableOperandsForFilter[0];
103109

110+
const { value } = getInitialFilterValue(
111+
filterType as FilterableAndTSVectorFieldType,
112+
defaultOperand,
113+
);
114+
104115
upsertStepFilterSettings({
105116
stepFilterToUpsert: {
106117
...stepFilter,
107118
stepOutputKey: rawVariableName,
108119
isFullRecord,
109120
type: filterType ?? 'unknown',
110-
value: '',
121+
value: value,
111122
fieldMetadataId,
112123
compositeFieldSubFieldName,
113124
operand: defaultOperand,
@@ -120,6 +131,7 @@ export const WorkflowDropdownStepOutputItems = ({
120131
getFieldMetadataItemByIdOrThrow,
121132
upsertStepFilterSettings,
122133
stepFilter,
134+
getInitialFilterValue,
123135
],
124136
);
125137

0 commit comments

Comments
 (0)