[react-form-start] Cannot restore form state after post-validation submission errors

Đang mở
#2,272 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
45/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
react, typescript
Lĩnh vực
frontend

Hướng nghiên cứu

Bắt đầu bằng cách theo dõi createServerValidate và luồng khôi phục ServerFormState trong @tanstack/react-form-start, tập trung vào các biểu mẫu POST gốc và chu kỳ chuyển hướng. Xác định cách một trạng thái tùy ý từ lỗi mutation sau khi xác thực có thể được lưu bền vững và khôi phục mà không điều hướng đến phản hồi thô của server-function. Hoàn thành khi các giá trị biểu mẫu và lỗi ở cấp trường hoặc cấp biểu mẫu vẫn tồn tại qua luồng POST/Redirect/GET thông qua một API công khai.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

v1 v2: needs investigation
Observed behavior

With a native TanStack Start form:

<form action={submitForm.url} method="post">

createServerValidate correctly preserves values and errors when server validation fails.

However, if validation succeeds and the subsequent mutation returns a domain error, there is no public API to persist an arbitrary ServerFormState across the redirect:

const values = await serverValidate(formData);
const result = await createResource(values);

if (!result.success) {
  // Cannot restore `values` with field/form errors after redirecting.
}

Returning the form state from the server function navigates the browser to the raw server-function response instead of restoring the original form.

Expected behavior

@tanstack/react-form-start should provide a public API to persist an arbitrary ServerFormState and redirect back to the form, using the same restoration mechanism as createServerValidate.

This would allow post-validation mutation errors to preserve submitted values and populate form-level or field-level errors after the POST/Redirect/GET cycle.

Version: @tanstack/[email protected]

Ngôn ngữ chính
TypeScript
Star
6.8k
Fork
705
Merge trung bình
1 ngày 12 giờ
Pull request đã merge (30 ngày)
14

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của TanStack/form

Tất cả issue của TanStack/form

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.