Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Fix: Clicking the save button on the Go version of the dataset configuration page automatically locates the field where the error occurred. (#19061)

balibabu8347d1c566fa
diff --git a/web/src/locales/zh.ts b/web/src/locales/zh.ts
index 73b5e4ac84..38c4b451f3 100644
--- a/web/src/locales/zh.ts
+++ b/web/src/locales/zh.ts
@@ -2242,6 +2242,7 @@ NER:使用 spaCy NER 和基于规则的关键词提取来抽取 Entities 和 R
'所有解析后的 sections 会按原始顺序合并为 1 个 chunk。',
flattenMediaToText: '禁用视觉模型',
flattenMediaToTextTip: '将图片和表格区块按普通文本处理,并跳过视觉增强。',
+ enableChildrenDelimiters: '子块用于检索',
merge: '合并',
split: '拆分',
script: '脚本',
diff --git a/web/src/pages/agent/constant/pipeline.tsx b/web/src/pages/agent/constant/pipeline.tsx
index 851a54ae41..170f5018a1 100644
--- a/web/src/pages/agent/constant/pipeline.tsx
+++ b/web/src/pages/agent/constant/pipeline.tsx
@@ -268,6 +268,8 @@ export const initialTokenChunkerValues = {
overlapped_percent: 0,
delimiters: [{ value: '\n' }],
image_table_context_window: 0,
+ enable_children: false,
+ children_delimiters: [],
};
export enum Hierarchy {
diff --git a/web/src/pages/agent/form/token-chunker-form/index.tsx b/web/src/pages/agent/form/token-chunker-form/index.tsx
index 90edfe48b6..b749f9efec 100644
--- a/web/src/pages/agent/form/token-chunker-form/index.tsx
+++ b/web/src/pages/agent/form/token-chunker-form/index.tsx
@@ -4,7 +4,7 @@ import { useSyncExternalFormErrors } from '@/components/pipeline-operator-tabs/u
import { RAGFlowFormItem } from '@/components/ragflow-form';
import { SliderInputFormField } from '@/components/slider-input-form-field';
import { BlockButton, Button } from '@/components/ui/button';
-import { Form, FormControl, FormField, FormItem } from '@/components/ui/form';
+import { Form } from '@/components/ui/form';
import { Switch } from '@/components/ui/switch';
import { zodResolver } from '@hookform/resolvers/zod';
import { isEmpty } from 'lodash';
@@ -178,21 +178,14 @@ const TokenChunkerForm = ({
<div className="mb-2 flex justify-between items-center gap-1">
<span>{t('flow.enableChildrenDelimiters')}</span>
- <FormField
- control={form.control}
- name="enable_children"
- render={({ field: { value, onChange, ...restProps } }) => (
- <FormItem>
- <FormControl>
- <Switch
- checked={value}
- onCheckedChange={onChange}
- {...restProps}
- />
- </FormControl>
- </FormItem>
+ <RAGFlowFormItem name="enable_children">
+ {(field) => (
+ <Switch
+ checked={field.value}
+ onCheckedChange={field.onChange}
+ />
)}
- />
+ </RAGFlowFormItem>
</div>
{form.getValues('enable_children') && (
diff --git a/web/src/pages/dataset/setting/go/index.tsx b/web/src/pages/dataset/setting/go/index.tsx
index bdc86fea9a..1ff0eb5c82 100644
--- a/web/src/pages/dataset/setting/go/index.tsx
+++ b/web/src/pages/dataset/setting/go/index.tsx
@@ -37,6 +37,7 @@ import {
usePipelineDataList,
useSaveDatasetSetting,
} from './hooks';
+import { useRevealSubmitErrors } from './use-reveal-submit-errors';
export default function DatasetSetting() {
const { t } = useTranslation();
@@ -129,6 +130,9 @@ export default function DatasetSetting() {
const { activeTab, setActiveTab } = useActiveTab(operatorNodes);
+ const { scrollContainerRef, handleInvalidSubmit } =
+ useRevealSubmitErrors(setActiveTab);
+
useEffect(() => {
if (parseType === ParseType.BuiltIn) {
form.setValue('pipeline_id', '');
@@ -144,17 +148,6 @@ export default function DatasetSetting() {
[handleSave],
);
- const onInvalid = useCallback(
- (errors: FieldErrors) => {
- // Surface the first failing operator tab so its field errors are visible.
- const firstOperatorId = Object.keys(errors?.parser_config ?? {})[0];
- if (firstOperatorId) {
- setActiveTab(firstOperatorId);
- }
- },
- [setActiveTab],
- );
-
const { errors } = useFormState({
control: form.control,
name: 'parser_config',
@@ -209,10 +202,13 @@ export default function DatasetSetting() {
<CardContent className="p-0 flex-1 h-0 flex divide-x-0.5">
<Form {...form}>
<form
- onSubmit={form.handleSubmit(handleSubmit, onInvalid)}
+ onSubmit={form.handleSubmit(handleSubmit, handleInvalidSubmit)}
className="flex flex-col"
>
- <div className="flex-1 h-0 w-[768px] px-5 pt-5 overflow-y-auto scrollbar-auto">
+ <div
+ ref={scrollContainerRef}
+ className="flex-1 h-0 w-[768px] px-5 pt-5 overflow-y-auto scrollbar-auto"
+ >
<section className="space-y-5 text-text-secondary">
<div className="text-base font-medium text-text-primary">
{t('knowledgeConfiguration.baseInfo')}
diff --git a/web/src/pages/dataset/setting/go/use-reveal-submit-errors.ts b/web/src/pages/dataset/setting/go/use-reveal-submit-errors.ts
new file mode 100644
index 0000000000..0fcd8d560b
--- /dev/null
+++ b/web/src/pages/dataset/setting/go/use-reveal-submit-errors.ts
@@ -0,0 +1,79 @@
+import {
+ Dispatch,
+ SetStateAction,
+ useCallback,
+ useEffect,
+ useRef,
+ useState,
+} from 'react';
+import { FieldErrors } from 'react-hook-form';
+
+// Elements that flag a validation error: the control marked by FormControl or
+// the message paragraph rendered by FormMessage.
+const ErrorIndicatorSelector =
+ '[aria-invalid="true"], [id$="-form-item-message"]';
+
+// Operator-tab errors surface asynchronously: the tab must mount and mirror
+// the outer form's errors onto its fields (a passive effect plus a re-render),
+// so the indicator may only appear several frames after the invalid submit.
+const MaxPollFrames = 30;
+
+/**
+ * Reveals validation errors after an invalid submit: surfaces the operator tab
+ * holding the first parser_config error and scrolls the first visible error
+ * into view. Only the form's own scroll container is scrolled, never the page.
+ * The signal counter re-triggers on every invalid submit, even when the active
+ * tab does not change.
+ */
+export function useRevealSubmitErrors(
+ setActiveTab: Dispatch<SetStateAction<string>>,
+) {
+ const [invalidSubmitSignal, setInvalidSubmitSignal] = useState(0);
+ const scrollContainerRef = useRef<HTMLDivElement>(null);
+
+ const handleInvalidSubmit = useCallback(
+ (errors: FieldErrors) => {
+ // Surface the first failing operator tab so its field errors are visible.
+ const firstOperatorId = Object.keys(errors?.parser_config ?? {})[0];
+ if (firstOperatorId) {
+ setActiveTab(firstOperatorId);
+ }
+ setInvalidSubmitSignal((signal) => signal + 1);
+ },
+ [setActiveTab],
+ );
+
+ useEffect(() => {
+ if (invalidSubmitSignal === 0) {
+ return;
+ }
+ let rafId = 0;
+ let polledFrames = 0;
+ const scrollToFirstError = () => {
+ const container = scrollContainerRef.current;
+ const target = container?.querySelector<HTMLElement>(
+ ErrorIndicatorSelector,
+ );
+ if (!container || !target) {
+ if (++polledFrames < MaxPollFrames) {
+ rafId = requestAnimationFrame(scrollToFirstError);
+ }
+ return;
+ }
+ // scrollIntoView({ block: 'center' }) restricted to the form's own
+ // scroll container, so the page itself is never pushed around.
+ const containerRect = container.getBoundingClientRect();
+ const targetRect = target.getBoundingClientRect();
+ const top =
+ targetRect.top -
+ containerRect.top +
+ container.scrollTop -
+ (container.clientHeight - targetRect.height) / 2;
+ container.scrollTo({ top, behavior: 'smooth' });
+ };
+ rafId = requestAnimationFrame(scrollToFirstError);
+ return () => cancelAnimationFrame(rafId);
+ }, [invalidSubmitSignal]);
+
+ return { scrollContainerRef, handleInvalidSubmit };
+}