fix(forms): handle nullable fields in deepMergeWithDefaults

When default value is null but source has a value (e.g., description
field), the merge was discarding the source value because typeof null
!== typeof string. Now properly accepts source values for nullable fields.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-06 13:54:18 +01:00
parent 3c6b14d2bf
commit 45025bb2f1
2 changed files with 13 additions and 0 deletions

View File

@@ -111,6 +111,10 @@ export function deepMergeWithDefaults<T extends Record<string, unknown>>(
if (typeof sourceValue === typeof defaultValue) {
result[key] = sourceValue as T[keyof T];
}
// Special case: default is null but source has a value (nullable fields)
else if (defaultValue === null && sourceValue !== null) {
result[key] = sourceValue as T[keyof T];
}
// Special case: allow null for nullable fields
else if (sourceValue === null && defaultValue === null) {
result[key] = null as T[keyof T];