Repository navigation
Conversation
…rver errors, save footer and leave guard Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # frontend/bun.lock
…4288-v1-form-system
…4288-v1-form-system
…eld, accept any error body
- Route server errors by mounted field, not by value: an error for a value no
field renders, or a schema refine with no path, now shows in the footer and
no longer locks Save.
- mode onTouched: a field that failed on blur clears as soon as it is fixed.
- Join several server errors on one attr; accept {detail}, {error} and
malformed bodies with a fallback message.
- Hide the form-level error once the change is reverted.
- Docs: reset(saved) after save, defaultValues read once, the leave guard is
caller-awaited; no plan task codes in comments.
- Tests for each, plus Saving/clean button states; drop unrelated bun.lock churn.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…en the error body guard - FormField clears its error on unmount, so the footer re-renders instead of staying on "Cannot save" with no message; a submit re-validates. - applyServerErrors skips null entries and non-string details, and takes the first non-blank detail, error or message before the generic fallback. - Tests: nested field through the footer, hide-then-error, no fallback when a field takes the error, whitespace and malformed bodies. Co-Authored-By: Claude Opus 5.5 <[email protected]>
athul-rs
added a commit
that referenced
this pull request
Nov 10, 2026
…est-branch history as a parent
A server field error disables Save, so focus left on the button fell to the page body (seen in Chrome on the dev namespace). applyServerErrors now focuses the first field it marks, as a failed client-side submit already does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What
frontend/src/v1/components/patterns/form/:useAppForm({schema, defaultValues}): react-hook-form with a zod schema. A field validates when it first loses focus, then on every change. A failed submit focuses the first invalid field.FormField: binds one value to the v1Fieldfrom P1-T03, so its error shows under the control and marks it invalid.applyServerErrors(form, body): puts each backend error (drf_standardized_errors) under the field itsattrnames when that field is on screen. Every other error, and any body of another shape, becomes one form-level message.FormFooter: No changes / N unsaved changes / Saving / Cannot save, with Save changes and Discard.useLeaveGuard(dirty, confirm): the browser asks before the tab closes while the form is dirty, and the returned function asksconfirmbefore a dialog closes or the caller navigates.@hookform/resolvers^7.0.3 andzod^4.6.7.react-hook-formis already on main.Why
How
{detail}(middleware),{error}(SDK handler) and malformed bodies fall back to their message or "Could not save. Try again."form.reset(saved)after a successful save. Discard and the change count compare against the last reset.Can this PR break any existing features. If yes, please list possible items. If no, please explain why. (PS: Admins do not merge the PR without this section filled)
frontend/src/v1, which no route renders yet. v0 does not import it. The two new packages are only imported from v1.Database Migrations
Env Config
Relevant Docs
83e4fffRelated Issues or PRs
main.FormFieldwhen they land.useBlocker). v0 mounts aBrowserRouter, souseLeaveGuardcovers tab close and caller-awaited dialog closes for now.useLeaveGuardtakesconfirm: () => Promise<boolean>; the shape is to be agreed.applyServerErrorsreads the raw backend body; it switches to the P0-T05 HTTP client's normalised error when that exists.Dependencies Versions
@hookform/resolvers^7.0.3 (new)zod^4.6.7 (new)Notes on Testing
form.test.tsx, 35 tests covering:typecheck:v1,lint:v1andbun install --frozen-lockfilepass.Screenshots
Checklist
I have read and understood the Contribution Guidelines.
🤖 Generated with Claude Code