Skip to content

Commit 9590f90

Browse files
committed
fix: prevent stale next_plan form data from overriding explicit null when switching users, ensuring the next-plan toggle resets correctly
1 parent 1123cfb commit 9590f90

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

dashboard/src/components/dialogs/user-modal.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,11 +357,17 @@ export default function UserModal({ isDialogOpen, onOpenChange, form, editingUse
357357
// This ensures we catch the data even if form hasn't been populated yet
358358
const nextPlanFromForm = form.getValues('next_plan')
359359
const nextPlanFromData = editingUserData?.next_plan
360+
if (nextPlanFromData === null) {
361+
// Prevent stale form data from overriding explicit nulls.
362+
form.setValue('next_plan', undefined, { shouldValidate: false, shouldDirty: false })
363+
}
360364

361365
// Use editingUserData if form doesn't have it yet, otherwise use form value
362-
const nextPlan = nextPlanFromForm !== null && nextPlanFromForm !== undefined
363-
? nextPlanFromForm
364-
: nextPlanFromData
366+
const nextPlan = nextPlanFromData === null
367+
? null
368+
: (nextPlanFromForm !== null && nextPlanFromForm !== undefined
369+
? nextPlanFromForm
370+
: nextPlanFromData)
365371

366372
const hasData = nextPlan !== null &&
367373
nextPlan !== undefined &&

0 commit comments

Comments
 (0)