RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
fix(web): clicking anywhere in a switch setting row toggles the switch (#18567)
euvre928743ff4000
diff --git a/web/src/components/__tests__/switch-fom-field.test.tsx b/web/src/components/__tests__/switch-fom-field.test.tsxnew file mode 100644index 0000000000..47655e0965--- /dev/null+++ b/web/src/components/__tests__/switch-fom-field.test.tsx@@ -0,0 +1,44 @@+import { Form } from '@/components/ui/form';+import { TooltipProvider } from '@/components/ui/tooltip';+import { fireEvent, render, screen } from '@testing-library/react';+import { useForm } from 'react-hook-form';+import { SwitchFormField } from '../switch-fom-field';++function Harness() {+ const form = useForm({ defaultValues: { flag: false } });+ return (+ <TooltipProvider>+ <Form {...form}>+ <SwitchFormField+ name="flag"+ label="Enable feature"+ tooltip="Explains the feature"+ />+ </Form>+ </TooltipProvider>+ );+}++describe('SwitchFormField', () => {+ it('toggles the switch when the label text is clicked', () => {+ render(<Harness />);+ const switchEl = screen.getByRole('switch');+ expect(switchEl).toHaveAttribute('data-state', 'unchecked');++ fireEvent.click(screen.getByText('Enable feature'));++ expect(switchEl).toHaveAttribute('data-state', 'checked');+ });++ it('does not toggle the switch when the tooltip icon is clicked', () => {+ const { container } = render(<Harness />);+ const switchEl = screen.getByRole('switch');+ expect(switchEl).toHaveAttribute('data-state', 'unchecked');++ const icon = container.querySelector('svg.lucide');+ expect(icon).not.toBeNull();+ fireEvent.click(icon!);++ expect(switchEl).toHaveAttribute('data-state', 'unchecked');+ });+});diff --git a/web/src/components/switch-fom-field.tsx b/web/src/components/switch-fom-field.tsxindex a4a31a0020..b6539ee445 100644--- a/web/src/components/switch-fom-field.tsx+++ b/web/src/components/switch-fom-field.tsx@@ -52,7 +52,9 @@ export function SwitchFormField({'justify-between': !vertical,})}>- <FormLabel tooltip={tooltip}>{label}</FormLabel>+ <FormLabel className="w-fit" tooltip={tooltip}>+ {label}+ </FormLabel><FormControl><Switchchecked={field.value}