AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
fix(frontend): allow empty values in number inputs and fix AnyOfField toggle (#11661)
lif01f443190e41
diff --git a/autogpt_platform/frontend/src/components/renderers/input-renderer/fields/AnyOfField/useAnyOfField.tsx b/autogpt_platform/frontend/src/components/renderers/input-renderer/fields/AnyOfField/useAnyOfField.tsxindex 7b35776476..073ed1f8e5 100644--- a/autogpt_platform/frontend/src/components/renderers/input-renderer/fields/AnyOfField/useAnyOfField.tsx+++ b/autogpt_platform/frontend/src/components/renderers/input-renderer/fields/AnyOfField/useAnyOfField.tsx@@ -64,7 +64,9 @@ export const useAnyOfField = (const [selectedType, setSelectedType] = useState<string>(initialSelectedType);- const isEnabled = formData !== null && formData !== undefined;+ // Only check for explicit null (set by toggle off), not undefined (empty input)+ // This allows users to clear number inputs without the field disappearing+ const isEnabled = formData !== null;const handleTypeChange = (t: string) => {setSelectedType(t);@@ -79,7 +81,13 @@ export const useAnyOfField = (}};- const handleValueChange = (value: any) => onChange(value);+ const handleValueChange = (value: any) => {+ if (isNullableType && value === null) {+ onChange(undefined);+ return;+ }+ onChange(value);+ };const currentTypeOption = typeOptions.find((o) => o.type === selectedType);diff --git a/autogpt_platform/frontend/src/components/renderers/input-renderer/widgets/TextInputWidget/TextInputWidget.tsx b/autogpt_platform/frontend/src/components/renderers/input-renderer/widgets/TextInputWidget/TextInputWidget.tsxindex d9fea28a8d..83fe826223 100644--- a/autogpt_platform/frontend/src/components/renderers/input-renderer/widgets/TextInputWidget/TextInputWidget.tsx+++ b/autogpt_platform/frontend/src/components/renderers/input-renderer/widgets/TextInputWidget/TextInputWidget.tsx@@ -51,7 +51,7 @@ export const TextInputWidget = (props: WidgetProps) => {handleChange: (v: string) => (v === "" ? undefined : Number(v)),},[InputType.INTEGER]: {- htmlType: "account",+ htmlType: "number",placeholder: "Enter integer value...",handleChange: (v: string) => (v === "" ? undefined : Number(v)),},