diff --git a/app/features/user-page/loaders/u.$identifier.builds.new.server.ts b/app/features/user-page/loaders/u.$identifier.builds.new.server.ts index 24b28d5d0..fc7170648 100644 --- a/app/features/user-page/loaders/u.$identifier.builds.new.server.ts +++ b/app/features/user-page/loaders/u.$identifier.builds.new.server.ts @@ -77,7 +77,7 @@ function resolveDefaultValues( buildToEdit?.shoesGearSplId === -1 ? null : buildToEdit?.shoesGearSplId, abilities, title: buildToEdit?.title, - description: buildToEdit?.description, + description: buildToEdit?.description ?? null, modes: buildToEdit?.modes ?? [], private: Boolean(buildToEdit?.private), }; diff --git a/app/form/SendouForm.tsx b/app/form/SendouForm.tsx index d00ba2ffb..577b3239b 100644 --- a/app/form/SendouForm.tsx +++ b/app/form/SendouForm.tsx @@ -389,8 +389,9 @@ function buildInitialValues( | FormField | undefined; - if (defaultValues && key in defaultValues) { - result[key] = defaultValues[key as keyof typeof defaultValues]; + const defaultValue = defaultValues?.[key as keyof typeof defaultValues]; + if (defaultValue !== undefined) { + result[key] = defaultValue; } else if (formField) { result[key] = formField.initialValue; } diff --git a/app/utils/zod.ts b/app/utils/zod.ts index f46ede24d..30b03ca56 100644 --- a/app/utils/zod.ts +++ b/app/utils/zod.ts @@ -192,7 +192,7 @@ export const safeNullableStringSchema = ({ max: number; }) => z.preprocess( - actuallyNonEmptyStringOrNull, + processMany(undefinedToNull, actuallyNonEmptyStringOrNull), z .string() .min(min ?? 0)