From 57ef96a45821fdf1a1b884222ad94954205875e6 Mon Sep 17 00:00:00 2001
From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com>
Date: Sat, 6 Jun 2026 14:05:03 -0600
Subject: [PATCH] fix: swarm health check fields not resetting to default
values (#4558)
Fixes #4553
- Replace z.coerce.number() with a custom transform that converts empty strings to undefined instead of 0
- Add value={field.value ?? ""} to numeric inputs so they visually clear when reset to undefined
---
.../cluster/swarm-forms/health-check-form.tsx | 21 ++++++++++++-------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/apps/dokploy/components/dashboard/application/advanced/cluster/swarm-forms/health-check-form.tsx b/apps/dokploy/components/dashboard/application/advanced/cluster/swarm-forms/health-check-form.tsx
index 06c8eb94a..0f640cc37 100644
--- a/apps/dokploy/components/dashboard/application/advanced/cluster/swarm-forms/health-check-form.tsx
+++ b/apps/dokploy/components/dashboard/application/advanced/cluster/swarm-forms/health-check-form.tsx
@@ -16,12 +16,17 @@ import {
import { Input } from "@/components/ui/input";
import { api } from "@/utils/api";
+const optionalNumber = z
+ .union([z.string(), z.number()])
+ .transform((val) => (val === "" ? undefined : Number(val)))
+ .optional();
+
export const healthCheckFormSchema = z.object({
Test: z.array(z.string()).optional(),
- Interval: z.coerce.number().optional(),
- Timeout: z.coerce.number().optional(),
- StartPeriod: z.coerce.number().optional(),
- Retries: z.coerce.number().optional(),
+ Interval: optionalNumber,
+ Timeout: optionalNumber,
+ StartPeriod: optionalNumber,
+ Retries: optionalNumber,
});
interface HealthCheckFormProps {
@@ -195,7 +200,7 @@ export const HealthCheckForm = ({ id, type }: HealthCheckFormProps) => {
Time between health checks (e.g., 10000000000 for 10 seconds)
-
+
@@ -212,7 +217,7 @@ export const HealthCheckForm = ({ id, type }: HealthCheckFormProps) => {
Maximum time to wait for health check response
-
+
@@ -229,7 +234,7 @@ export const HealthCheckForm = ({ id, type }: HealthCheckFormProps) => {
Initial grace period before health checks begin
-
+
@@ -247,7 +252,7 @@ export const HealthCheckForm = ({ id, type }: HealthCheckFormProps) => {
unhealthy
-
+