From f8a5681b88dfb6f8ce3ee8aedb06dd3ccf7d6730 Mon Sep 17 00:00:00 2001 From: Colin Dawson Date: Sat, 31 Jan 2026 22:23:55 +0000 Subject: [PATCH] Fixed circular call issue --- src/components/common/TemplateFiller.tsx | 3 ++- .../specifications/SpecificationsDetails.tsx | 20 ++++++------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/components/common/TemplateFiller.tsx b/src/components/common/TemplateFiller.tsx index cae9c81..35927a1 100644 --- a/src/components/common/TemplateFiller.tsx +++ b/src/components/common/TemplateFiller.tsx @@ -112,7 +112,8 @@ const TemplateFiller = forwardRef( customFields: newCustomFields, }); setTemplate(newTemplate); - }, [templateId, formInstanceId, form]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [templateId, formInstanceId]); useEffect(() => { void loadTemplate(); diff --git a/src/modules/manager/specifications/SpecificationsDetails.tsx b/src/modules/manager/specifications/SpecificationsDetails.tsx index f618575..518260c 100644 --- a/src/modules/manager/specifications/SpecificationsDetails.tsx +++ b/src/modules/manager/specifications/SpecificationsDetails.tsx @@ -71,17 +71,13 @@ const SpecificationsDetails: React.FC = ({ const isEditMode = () => editMode; const loadFormTemplate = useCallback( - async (printSpecifications?: GeneralIdRef) => { - const { data } = form.state; - const printSpecArray = - (data.printSpecifications as CustomFieldValue[]) || []; - + async (printSpecArray: CustomFieldValue[]) => { if (printSpecArray && printSpecArray.length > 0) { if ( ((printSpecArray[0] as CustomFieldValue).value as GeneralIdRef).id === BigInt(0) ) { - data.printSpecifications = undefined; + return; } } @@ -95,12 +91,9 @@ const SpecificationsDetails: React.FC = ({ } if (template) { setFormTemplate(template); - form.setState({ loaded: true }); - } else { - form.setState({ loaded: false }); } }, - [form], + [], ); const handleValidationChanged = useCallback(() => { @@ -142,11 +135,10 @@ const SpecificationsDetails: React.FC = ({ const { printSpecifications } = form.state.data; const printSpecArray = (printSpecifications as CustomFieldValue[]) || []; if (printSpecArray && printSpecArray.length > 0) { - loadFormTemplate( - (printSpecArray[0] as CustomFieldValue).value as GeneralIdRef, - ); + loadFormTemplate(printSpecArray); } - }, [form.state.data.printSpecifications, loadFormTemplate, form]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [form.state.data.printSpecifications]); const doSubmit = async (buttonName: string) => { try {