Skip to content

Commit ccbf372

Browse files
committed
feat: refactor FieldValue component to improve reference source handling
1 parent 7ef8184 commit ccbf372

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

apps/nestjs-backend/src/features/record/query-builder/formula-support-generated-column-validator.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable sonarjs/no-identical-functions */
12
import type {
23
TableDomain,
34
IFunctionCallInfo,

packages/sdk/src/components/filter/view-filter/custom-component/FieldValue.tsx

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,21 @@ export const FieldValue = <T extends IConditionItemProperty = IViewFilterConditi
2525
const field = fields.find((f) => f.id === item.field);
2626

2727
const defaultReferenceSource = useMemo<IFilterReferenceSource | undefined>(() => {
28-
if (!field) {
29-
return referenceSource;
28+
if (!referenceSource) {
29+
return undefined;
3030
}
31-
if (referenceSource?.fields?.length) {
31+
if (referenceSource.tableId) {
3232
return referenceSource;
3333
}
34-
const candidates = field.tableId
35-
? fields.filter((candidate) => candidate.tableId === field.tableId)
36-
: fields;
37-
if (!candidates.length) {
34+
const fallbackTableId = referenceSource.fields[0]?.tableId ?? field?.tableId;
35+
if (!fallbackTableId) {
3836
return referenceSource;
3937
}
4038
return {
41-
fields: candidates,
42-
tableId: field.tableId ?? candidates[0]?.tableId,
39+
...referenceSource,
40+
tableId: fallbackTableId,
4341
};
44-
}, [field, fields, referenceSource]);
42+
}, [field?.tableId, referenceSource]);
4543

4644
return (
4745
<BaseFieldValue

0 commit comments

Comments
 (0)