diff --git a/src/frontend/src/modals/genericModal/index.tsx b/src/frontend/src/modals/genericModal/index.tsx index e82b40fbb..c3f091ce0 100644 --- a/src/frontend/src/modals/genericModal/index.tsx +++ b/src/frontend/src/modals/genericModal/index.tsx @@ -109,6 +109,13 @@ export default function GenericModal({ postValidatePrompt(field_name, inputValue, nodeClass!) .then((apiReturn) => { + // if field_name is an empty string, then we need to set it + // to the first key of the custom_fields object + if (field_name === "") { + field_name = Object.keys( + apiReturn.data?.frontend_node?.custom_fields ?? {} + )[0]; + } if (apiReturn.data) { let inputVariables = apiReturn.data.input_variables ?? []; if (inputVariables && inputVariables.length === 0) { @@ -124,7 +131,7 @@ export default function GenericModal({ setNodeClass!(apiReturn.data?.frontend_node); setModalOpen(closeModal); setValue(inputValue); - apiReturn.data.frontend_node["template"]["template"]["value"] = + apiReturn.data.frontend_node["template"][field_name]["value"] = inputValue; } else { setIsEdit(false); @@ -138,7 +145,7 @@ export default function GenericModal({ setNodeClass!(apiReturn.data?.frontend_node); setModalOpen(closeModal); setValue(inputValue); - apiReturn.data.frontend_node["template"]["template"]["value"] = + apiReturn.data.frontend_node["template"][field_name]["value"] = inputValue; } } else { diff --git a/src/frontend/src/types/api/index.ts b/src/frontend/src/types/api/index.ts index ad867d12d..42ec05ead 100644 --- a/src/frontend/src/types/api/index.ts +++ b/src/frontend/src/types/api/index.ts @@ -7,6 +7,11 @@ export type APITemplateType = { variable: TemplateVariableType; [key: string]: TemplateVariableType; }; + +export type CustomFieldsType = { + [key: string]: Array; +}; + export type APIClassType = { base_classes: Array; description: string; @@ -14,10 +19,17 @@ export type APIClassType = { display_name: string; input_types?: Array; output_types?: Array; + custom_fields?: CustomFieldsType; beta?: boolean; documentation: string; error?: string; - [key: string]: Array | string | APITemplateType | boolean | undefined; + [key: string]: + | Array + | string + | APITemplateType + | CustomFieldsType + | boolean + | undefined; }; export type TemplateVariableType = {