mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
fix(frontend): Fix input-field update on empty & default value (#8647)
* fix(frontend): Fix input-field update on empty & default value * Fix error message * Revert
This commit is contained in:
@@ -22,6 +22,7 @@ import {
|
||||
beautifyString,
|
||||
cn,
|
||||
getValue,
|
||||
hasNonNullNonObjectValue,
|
||||
parseKeys,
|
||||
setNestedProperty,
|
||||
} from "@/lib/utils";
|
||||
@@ -239,7 +240,10 @@ export function CustomNode({
|
||||
nodeId={id}
|
||||
propKey={getInputPropKey(propKey)}
|
||||
propSchema={propSchema}
|
||||
currentValue={getValue(propKey, data.hardcodedValues)}
|
||||
currentValue={getValue(
|
||||
getInputPropKey(propKey),
|
||||
data.hardcodedValues,
|
||||
)}
|
||||
connections={data.connections}
|
||||
handleInputChange={handleInputChange}
|
||||
handleInputClick={handleInputClick}
|
||||
@@ -384,9 +388,7 @@ export function CustomNode({
|
||||
});
|
||||
}, [id, data, height, addNodes, deleteElements, getNode, getNextNodeId]);
|
||||
|
||||
const hasConfigErrors =
|
||||
data.errors &&
|
||||
Object.entries(data.errors).some(([_, value]) => value !== null);
|
||||
const hasConfigErrors = data.errors && hasNonNullNonObjectValue(data.errors);
|
||||
const outputData = data.executionResults?.at(-1)?.data;
|
||||
const hasOutputError =
|
||||
typeof outputData === "object" &&
|
||||
@@ -396,8 +398,8 @@ export function CustomNode({
|
||||
useEffect(() => {
|
||||
if (hasConfigErrors) {
|
||||
const filteredErrors = Object.fromEntries(
|
||||
Object.entries(data.errors || {}).filter(
|
||||
([_, value]) => value !== null,
|
||||
Object.entries(data.errors || {}).filter(([, value]) =>
|
||||
hasNonNullNonObjectValue(value),
|
||||
),
|
||||
);
|
||||
console.error(
|
||||
|
||||
@@ -322,7 +322,7 @@ const NodeCredentialsInput: FC<{
|
||||
};
|
||||
|
||||
const InputRef = (value: any): ((el: HTMLInputElement | null) => void) => {
|
||||
return (el) => el && value && (el.value = value);
|
||||
return (el) => el && value != null && (el.value = value);
|
||||
};
|
||||
|
||||
const NodeKeyValueInput: FC<{
|
||||
|
||||
@@ -314,6 +314,14 @@ export function findNewlyAddedBlockCoordinates(
|
||||
};
|
||||
}
|
||||
|
||||
export function hasNonNullNonObjectValue(obj: any): boolean {
|
||||
if (obj !== null && typeof obj === "object") {
|
||||
return Object.values(obj).some((value) => hasNonNullNonObjectValue(value));
|
||||
} else {
|
||||
return obj !== null && typeof obj !== "object";
|
||||
}
|
||||
}
|
||||
|
||||
type ParsedKey = { key: string; index?: number };
|
||||
|
||||
export function parseKeys(key: string): ParsedKey[] {
|
||||
|
||||
Reference in New Issue
Block a user