Browse Source

fix(dashboard): Preserve string arg values without JSON parsing in form inputs (#4156)

gabriellbui 2 days ago
parent
commit
550242f91e

+ 1 - 1
packages/dashboard/src/lib/components/data-input/text-input.tsx

@@ -12,5 +12,5 @@ import { isReadonlyField } from '@/vdb/framework/form-engine/utils.js';
  */
  */
 export const TextInput: DashboardFormComponent = ({ value, onChange, fieldDef }) => {
 export const TextInput: DashboardFormComponent = ({ value, onChange, fieldDef }) => {
     const readOnly = isReadonlyField(fieldDef);
     const readOnly = isReadonlyField(fieldDef);
-    return <Input value={value || ''} onChange={e => onChange(e.target.value)} disabled={readOnly} />;
+    return <Input value={value ?? ''} onChange={e => onChange(e.target.value)} disabled={readOnly} />;
 };
 };

+ 6 - 0
packages/dashboard/src/lib/framework/form-engine/value-transformers.ts

@@ -40,6 +40,12 @@ export const jsonStringValueTransformer: ValueTransformer = {
             return value;
             return value;
         }
         }
 
 
+        // For scalar string fields, return the raw value without JSON parsing.
+        // This prevents issues like "0" being parsed as number 0, or "-0" becoming -0 which is "0" in the input.
+        if (fieldDef.type === 'string' && !fieldDef.list) {
+            return value;
+        }
+
         try {
         try {
             // For JSON string mode, parse the string to get the native value
             // For JSON string mode, parse the string to get the native value
             const parsed = JSON.parse(value);
             const parsed = JSON.parse(value);