@@ -12,5 +12,5 @@ import { isReadonlyField } from '@/vdb/framework/form-engine/utils.js';
*/
export const TextInput: DashboardFormComponent = ({ value, onChange, 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} />;
};
@@ -40,6 +40,12 @@ export const jsonStringValueTransformer: ValueTransformer = {
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 {
// For JSON string mode, parse the string to get the native value
const parsed = JSON.parse(value);