mirror of
https://github.com/twentyhq/twenty.git
synced 2026-05-19 22:07:21 -04:00
fix(advanced-filter): exclude many-to-one relations from relation target picker
The backend supports a single-hop relation traversal. If the user picked a many-to-one relation field as the target, the dispatcher would substitute the target id into fieldMetadataId and recurse — the inner call has relationTargetFieldMetadataId set to null, so it falls through to the per-type RELATION case which expects a UUID list, not a primitive value. The UI offered a traversal that the backend silently demoted to filter-by-id. Filter many-to-one fields out of the target list so only one-hop traversals can be composed.
This commit is contained in:
@@ -62,9 +62,17 @@ export const AdvancedFilterRelationTargetFieldSelectMenu = ({
|
||||
? sourceFieldMetadataItem.relation.targetObjectMetadata.id
|
||||
: null;
|
||||
|
||||
const { filterableFieldMetadataItems: relationTargetFields } =
|
||||
const { filterableFieldMetadataItems: allTargetFields } =
|
||||
useFilterableFieldMetadataItems(targetObjectMetadataId ?? '');
|
||||
|
||||
// The backend supports a single hop only. Exclude many-to-one relations
|
||||
// from the target list so the user can't compose multi-hop traversals
|
||||
// (e.g. Person → Company → ParentCompany) that the dispatcher would
|
||||
// collapse back to a filter-by-id on the intermediate relation.
|
||||
const relationTargetFields = allTargetFields.filter(
|
||||
(field) => !isManyToOneRelationField(field),
|
||||
);
|
||||
|
||||
if (
|
||||
!isDefined(sourceFieldMetadataItem) ||
|
||||
!isManyToOneRelationField(sourceFieldMetadataItem)
|
||||
|
||||
Reference in New Issue
Block a user