Skip to content

Commit cc255ad

Browse files
committed
Refactor FieldsTagsEditor to use Form.useWatch for correct_answer_key reactivity
- Updated FieldsTagsEditor component to utilize Form.useWatch instead of form.getFieldValue for monitoring changes to correct_answer_key. - This change enhances reactivity and ensures the component responds appropriately to form updates.
1 parent e0c2564 commit cc255ad

File tree

1 file changed

+4
-3
lines changed
  • web/oss/src/components/pages/evaluations/autoEvaluation/EvaluatorsModal/ConfigureEvaluator

1 file changed

+4
-3
lines changed

web/oss/src/components/pages/evaluations/autoEvaluation/EvaluatorsModal/ConfigureEvaluator/FieldsTagsEditor.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import {useCallback, useEffect, useMemo, useRef, useState} from "react"
1818

1919
import {PlusOutlined, SearchOutlined} from "@ant-design/icons"
20-
import {Button, Input, Tag, Tooltip, Typography} from "antd"
20+
import {Button, Form, Input, Tag, Tooltip, Typography} from "antd"
2121
import type {FormInstance} from "antd/es/form"
2222
import {useAtomValue} from "jotai"
2323

@@ -53,8 +53,9 @@ export const FieldsTagsEditor: React.FC<FieldsTagsEditorProps> = ({
5353
const testcaseSelection = useAtomValue(playgroundSelectedTestcaseAtom)
5454
const testcase = testcaseSelection?.testcase
5555

56-
// Get the correct_answer_key from form if available
57-
const formCorrectAnswerKey = form?.getFieldValue(["settings_values", "correct_answer_key"])
56+
// Watch the correct_answer_key from form to react to changes
57+
// Using Form.useWatch instead of form.getFieldValue for reactivity
58+
const formCorrectAnswerKey = Form.useWatch(["settings_values", "correct_answer_key"], form)
5859
const effectiveKey = formCorrectAnswerKey || correctAnswerKey
5960

6061
// Check if we can detect fields from testcase

0 commit comments

Comments
 (0)