diff --git a/client/src/components/DynamicJsonForm.tsx b/client/src/components/DynamicJsonForm.tsx index 2f38da29e..ecd150f22 100644 --- a/client/src/components/DynamicJsonForm.tsx +++ b/client/src/components/DynamicJsonForm.tsx @@ -28,6 +28,7 @@ interface DynamicJsonFormProps { export interface DynamicJsonFormRef { validateJson: () => { isValid: boolean; error: string | null }; + hasJsonError: () => boolean; } const isTypeSupported = ( @@ -129,6 +130,10 @@ const DynamicJsonForm = forwardRef( // on every keystroke which would be inefficient and error-prone const timeoutRef = useRef>(); + const hasJsonError = () => { + return !!jsonError; + }; + // Debounce JSON parsing and parent updates to handle typing gracefully const debouncedUpdateParent = useCallback( (jsonString: string) => { @@ -253,6 +258,7 @@ const DynamicJsonForm = forwardRef( useImperativeHandle(ref, () => ({ validateJson, + hasJsonError, })); const renderFormFields = ( diff --git a/client/src/components/ToolsTab.tsx b/client/src/components/ToolsTab.tsx index d872e6299..9e1b5d56b 100644 --- a/client/src/components/ToolsTab.tsx +++ b/client/src/components/ToolsTab.tsx @@ -102,9 +102,11 @@ const ToolsTab = ({ const { copied, setCopied } = useCopy(); // Function to check if any form has validation errors - const checkValidationErrors = () => { + const checkValidationErrors = (validateChildren: boolean = false) => { const errors = Object.values(formRefs.current).some( - (ref) => ref && !ref.validateJson().isValid, + (ref) => + ref && + (validateChildren ? !ref.validateJson().isValid : ref.hasJsonError()), ); setHasValidationErrors(errors); return errors; @@ -675,7 +677,7 @@ const ToolsTab = ({