diff --git a/packages/core/client/src/schema-component/antd/form-v2/Templates.tsx b/packages/core/client/src/schema-component/antd/form-v2/Templates.tsx index 2324ca9a8..73e14b2e9 100644 --- a/packages/core/client/src/schema-component/antd/form-v2/Templates.tsx +++ b/packages/core/client/src/schema-component/antd/form-v2/Templates.tsx @@ -101,7 +101,11 @@ export const Templates = ({ style = {}, form }) => { } } }, []); - + useEffect(() => { + if (!templateOptions?.some((v) => v.key === targetTemplate)) { + handleTemplateChange('none'); + } + }, [templateOptions]); const wrapperStyle = useMemo(() => { return { display: 'flex', alignItems: 'center', backgroundColor: token.colorFillAlter, padding: '1em', ...style }; }, [style, token.colorFillAlter]); @@ -115,7 +119,7 @@ export const Templates = ({ style = {}, form }) => { return { fontSize: token.fontSize, fontWeight: 'bold', whiteSpace: 'nowrap', marginRight: token.marginXS }; }, [token.fontSize, token.marginXS]); - const handleTemplateChange = useCallback(async (value, option) => { + const handleTemplateChange = useCallback(async (value) => { setTargetTemplate(value); setTemplateData(null); form?.reset(); @@ -148,7 +152,6 @@ export const Templates = ({ style = {}, form }) => { return null; } const template = templateOptions?.find((v) => v.key === targetTemplate); - return (
@@ -160,7 +163,7 @@ export const Templates = ({ style = {}, form }) => { value={targetTemplate} onChange={handleTemplateChange} /> - {targetTemplate !== 'none' && ( + {targetTemplate !== 'none' && template && (