Skip to content

Commit 542cc25

Browse files
committed
fix: unable to submit in operation set editor
1 parent 9aa2605 commit 542cc25

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/components/operation-set/OperationSetEditor.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ function OperationSetForm({ operationSet, onSubmit }: FormProps) {
180180
control,
181181
handleSubmit,
182182
setError,
183-
formState: { errors, isDirty, isSubmitting },
183+
formState: { errors, isSubmitting },
184184
} = useForm<FormValues>({
185185
defaultValues: operationSet || {
186186
name: '',
@@ -220,7 +220,7 @@ function OperationSetForm({ operationSet, onSubmit }: FormProps) {
220220
<div className="grow">
221221
<OperationSelector
222222
operationSet={operationSet}
223-
ref={operationSelectorRef}
223+
selectorRef={operationSelectorRef}
224224
/>
225225
</div>
226226
</>
@@ -302,7 +302,7 @@ function OperationSetForm({ operationSet, onSubmit }: FormProps) {
302302
)}
303303

304304
<Button
305-
disabled={!isDirty || isSubmitting}
305+
disabled={isSubmitting}
306306
intent="primary"
307307
loading={isSubmitting}
308308
type="submit"
@@ -326,14 +326,17 @@ interface OperationSelectorProps {
326326
operationSet: OperationSet
327327

328328
// 这个组件做成受控组件的话,输入输出比较难处理,所以做成非受控组件,用 ref 获取值
329-
ref: Ref<OperationSelectorRef>
329+
selectorRef: Ref<OperationSelectorRef>
330330
}
331331

332332
interface OperationSelectorRef {
333333
getValues(): { idsToAdd: number[]; idsToRemove: number[] }
334334
}
335335

336-
function OperationSelector({ operationSet, ref }: OperationSelectorProps) {
336+
function OperationSelector({
337+
operationSet,
338+
selectorRef,
339+
}: OperationSelectorProps) {
337340
const { operations, error } = useOperations({
338341
operationIds: operationSet.copilotIds,
339342
})
@@ -348,7 +351,7 @@ function OperationSelector({ operationSet, ref }: OperationSelectorProps) {
348351
)
349352

350353
useImperativeHandle(
351-
ref,
354+
selectorRef,
352355
() => ({
353356
getValues() {
354357
const idsToAdd: number[] = []

0 commit comments

Comments
 (0)