From 1ffccd70de446762e86a42050965bbf05b63e15c Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Wed, 21 Jan 2026 18:15:26 +0200 Subject: [PATCH] Fix can't submit build without description --- .../user-page/loaders/u.$identifier.builds.new.server.ts | 2 +- app/form/SendouForm.tsx | 5 +++-- app/utils/zod.ts | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) 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)