mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-26 00:46:52 +08:00
Feat: Add InnerBlurInput component to avoid frequent updates of zustand causing the input box to lose focus #3221 (#7955)
### What problem does this PR solve? Feat: Add InnerBlurInput component to avoid frequent updates of zustand causing the input box to lose focus #3221 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -11,6 +11,7 @@ import { RAGFlowNodeType } from '@/interfaces/database/flow';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import { get, isPlainObject, lowerFirst } from 'lodash';
|
||||
import omit from 'lodash/omit';
|
||||
import { Play, X } from 'lucide-react';
|
||||
import { useEffect, useRef } from 'react';
|
||||
import { useForm } from 'react-hook-form';
|
||||
@ -54,7 +55,7 @@ const FormSheet = ({
|
||||
const OperatorForm = currentFormMap.component ?? EmptyContent;
|
||||
|
||||
const form = useForm({
|
||||
defaultValues: currentFormMap.defaultValues,
|
||||
values: currentFormMap.defaultValues,
|
||||
resolver: zodResolver(currentFormMap.schema),
|
||||
});
|
||||
|
||||
@ -89,10 +90,16 @@ const FormSheet = ({
|
||||
if (isPlainObject(formData)) {
|
||||
// form.setFieldsValue({ ...formData, items });
|
||||
console.info('xxx');
|
||||
form.reset({ ...formData, items });
|
||||
const nextValues = {
|
||||
...omit(formData, 'category_description'),
|
||||
items,
|
||||
};
|
||||
// Object.entries(nextValues).forEach(([key, value]) => {
|
||||
// form.setValue(key, value, { shouldDirty: false });
|
||||
// });
|
||||
form.reset(nextValues);
|
||||
}
|
||||
}
|
||||
if (operatorName === Operator.Message) {
|
||||
} else if (operatorName === Operator.Message) {
|
||||
form.reset({
|
||||
...formData,
|
||||
content: convertToObjectArray(formData.content),
|
||||
|
||||
@ -124,15 +124,26 @@ export function useFormConfigMap() {
|
||||
presencePenaltyEnabled: true,
|
||||
frequencyPenaltyEnabled: true,
|
||||
maxTokensEnabled: true,
|
||||
items: [],
|
||||
},
|
||||
schema: z.object({
|
||||
parameter: z.string().optional(),
|
||||
...LlmSettingSchema,
|
||||
message_history_window_size: z.number(),
|
||||
message_history_window_size: z.coerce.number(),
|
||||
items: z.array(
|
||||
z.object({
|
||||
name: z.string().min(1, t('flow.nameMessage')).trim(),
|
||||
}),
|
||||
z
|
||||
.object({
|
||||
name: z.string().min(1, t('flow.nameMessage')).trim(),
|
||||
description: z.string().optional(),
|
||||
// examples: z
|
||||
// .array(
|
||||
// z.object({
|
||||
// value: z.string(),
|
||||
// }),
|
||||
// )
|
||||
// .optional(),
|
||||
})
|
||||
.optional(),
|
||||
),
|
||||
}),
|
||||
},
|
||||
@ -180,6 +191,12 @@ export function useFormConfigMap() {
|
||||
arguments: z.array(
|
||||
z.object({ name: z.string(), component_id: z.string() }),
|
||||
),
|
||||
return: z.union([
|
||||
z
|
||||
.array(z.object({ name: z.string(), component_id: z.string() }))
|
||||
.optional(),
|
||||
z.object({ name: z.string(), component_id: z.string() }),
|
||||
]),
|
||||
}),
|
||||
},
|
||||
[Operator.WaitingDialogue]: {
|
||||
|
||||
Reference in New Issue
Block a user