Fix the default value of search record if the filter is boolean type (#17297)

This fixes the #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
3ce05fa31aec1c9e771cb1b3ff20ddea3fab304f. 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>
This commit is contained in:
Aman Raj
2026-01-25 03:57:05 +05:30
committed by GitHub
parent fa0615d41e
commit 62845cac87
2 changed files with 21 additions and 2 deletions
@@ -55,6 +55,13 @@ export const useGetInitialFilterValue = () => {
return { value: '', displayValue: '' };
}
break;
}
case 'BOOLEAN': {
if (newOperand === RecordFilterOperand.IS) {
return { value: 'false', displayValue: 'false' };
}
break;
}
}
@@ -5,6 +5,7 @@ import { DropdownMenuSeparator } from '@/ui/layout/dropdown/components/DropdownM
import { useGetFieldMetadataItemByIdOrThrow } from '@/object-metadata/hooks/useGetFieldMetadataItemById';
import { useObjectMetadataItems } from '@/object-metadata/hooks/useObjectMetadataItems';
import { useGetInitialFilterValue } from '@/object-record/object-filter-dropdown/hooks/useGetInitialFilterValue';
import { DropdownContent } from '@/ui/layout/dropdown/components/DropdownContent';
import { DropdownMenuHeaderLeftComponent } from '@/ui/layout/dropdown/components/DropdownMenuHeader/internal/DropdownMenuHeaderLeftComponent';
import { GenericDropdownContentWidth } from '@/ui/layout/dropdown/constants/GenericDropdownContentWidth';
@@ -22,7 +23,10 @@ import { getVariableTemplateFromPath } from '@/workflow/workflow-variables/utils
import { searchVariableThroughOutputSchemaV2 } from '@/workflow/workflow-variables/utils/searchVariableThroughOutputSchemaV2';
import { useLingui } from '@lingui/react/macro';
import { useRecoilCallback } from 'recoil';
import { type StepFilter } from 'twenty-shared/types';
import {
type FilterableAndTSVectorFieldType,
type StepFilter,
} from 'twenty-shared/types';
import { isDefined } from 'twenty-shared/utils';
import { extractRawVariableNamePart } from 'twenty-shared/workflow';
import {
@@ -55,6 +59,8 @@ export const WorkflowDropdownStepOutputItems = ({
const workflowVersionId = useWorkflowVersionIdOrThrow();
const { objectMetadataItems } = useObjectMetadataItems();
const { getInitialFilterValue } = useGetInitialFilterValue();
const updateStepFilter = useRecoilCallback(
({ snapshot }) =>
({
@@ -101,13 +107,18 @@ export const WorkflowDropdownStepOutputItems = ({
});
const defaultOperand = availableOperandsForFilter[0];
const { value } = getInitialFilterValue(
filterType as FilterableAndTSVectorFieldType,
defaultOperand,
);
upsertStepFilterSettings({
stepFilterToUpsert: {
...stepFilter,
stepOutputKey: rawVariableName,
isFullRecord,
type: filterType ?? 'unknown',
value: '',
value: value,
fieldMetadataId,
compositeFieldSubFieldName,
operand: defaultOperand,
@@ -120,6 +131,7 @@ export const WorkflowDropdownStepOutputItems = ({
getFieldMetadataItemByIdOrThrow,
upsertStepFilterSettings,
stepFilter,
getInitialFilterValue,
],
);