Skip to content

Commit 7208e66

Browse files
committed
Fixed tainted check when updating $form from server.
1 parent 4e5cb3c commit 7208e66

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/lib/client/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ export type TaintOption<T extends AnyZodObject = AnyZodObject> =
203203
| boolean
204204
| 'untaint'
205205
| 'untaint-all'
206+
| 'ignore'
206207
| { fields: FormPathLeaves<z.infer<T>> | FormPathLeaves<z.infer<T>>[] };
207208

208209
type SuperFormData<T extends ZodValidation<AnyZodObject>> = {
@@ -695,6 +696,11 @@ export function superForm<
695696
compareAgainst: unknown,
696697
taintOptions: TaintOption<UnwrappedT>
697698
) {
699+
// Ignore is set when returning errors from the server
700+
// so status messages and form-level errors won't be
701+
// immediately cleared by client-side validation.
702+
if (taintOptions == 'ignore') return;
703+
698704
let paths = comparePaths(newObj, compareAgainst);
699705

700706
if (typeof taintOptions === 'object') {
@@ -803,7 +809,7 @@ export function superForm<
803809
// Form data is not tainted when rebinding.
804810
// Prevents object errors from being revalidated after rebind.
805811
// eslint-disable-next-line dci-lint/private-role-access
806-
Form.set(form.data, { taint: false });
812+
Form.set(form.data, { taint: 'ignore' });
807813
Message.set(message);
808814
Errors.set(form.errors);
809815
FormId.set(form.id);

0 commit comments

Comments
 (0)