Frontend: document form validation rules and error copy register#49041
Frontend: document form validation rules and error copy register#49041RachelElysia wants to merge 4 commits into
Conversation
Extend Data validation in frontend/docs/patterns.md with 10 subsections (timing, clearing, priority, submit state, server-side errors, conditional validation, optional/disabled fields, input hygiene, in-flight lifecycle, visual affordances, copy register). Add matching terse rules under a new Validation section in .claude/rules/fleet-frontend.md.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #49041 +/- ##
========================================
Coverage 68.11% 68.11%
========================================
Files 3731 3731
Lines 235434 235434
Branches 12520 12371 -149
========================================
Hits 160371 160371
Misses 60670 60670
Partials 14393 14393
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Shorten the Validation section in .claude/rules/fleet-frontend.md to a strong "read patterns.md" trigger plus a handful of Fleet-specific anti-defaults, so validation guidance lives in one place. Drop the "shared validation hook is planned" mention and the backend/UI field key mapping bullet.
Note that GitOps mode disabling the whole form is a valid reason to disable the submit button. Explain why field errors clear on focus: the error text replaces the label, so clearing on focus restores the label the user needs to see while editing.
Name the mainstream React libraries (Formik, react-hook-form, MUI, Ant Design) Fleet diverges from and the four categories where it diverges, so the anti-defaults list has clearer motivation.
|
|
||
| - Trim leading and trailing whitespace client-side before submitting. Send the trimmed value to the API. | ||
| - Whitespace-only content in a required field counts as empty. | ||
| - Cap free-text `maxLength` to the backend column length via `inputOptions={{ maxLength: N }}` on `InputField`. The native input silently truncates paste. See [Forms](#forms) in the top-level rules. |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates Fleet’s frontend documentation to standardize React form validation behavior and UX conventions (error timing/placement, submit behavior, copy).
Changes:
- Rewrites
frontend/docs/patterns.mdform validation guidance with detailed rules for error display/clearing, submit state, server errors, and lifecycle. - Adds an authoritative pointer and summary checklist to
.claude/rules/fleet-frontend.mdto steer contributors toward the patterns doc.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| frontend/docs/patterns.md | Expands and clarifies form validation/UX rules (submit behavior, touched semantics, server errors, lifecycle, copy). |
| .claude/rules/fleet-frontend.md | Adds a “Validation” rules section that links to the authoritative patterns doc and summarizes key divergences. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - Never show a field's error before the user has interacted with that field. A field becomes interacted-with when the user types into it or blurs it while it holds a value. | ||
| - On blur of a field the user has interacted with, run validation and show the resulting error (if any) for that field only. Do not touch errors on other fields. | ||
| - On submit, show inline errors on every invalid field simultaneously, then return without submitting. | ||
| - Autofill counts as user interaction — treat autofilled fields as touched. | ||
| - On an Edit form, pre-filled values that are invalid do not show errors until the user interacts with the field. |
| - On focus (click-in) of a field that has an error, clear that field's error immediately — do not wait for the user to type a valid value. The error text replaces the field's label (see [Visual affordances](#visual-affordances)), so clearing on focus restores the label and lets the user see what they're editing. | ||
| - Re-validate on blur, not on keystroke. | ||
| - Typing in one field never clears errors on other fields. Clearing is per-field. | ||
| - When a validation becomes irrelevant (e.g. a conditional requirement is removed by toggling a checkbox), clear the newly-irrelevant error immediately. |
|
|
||
| - Trim leading and trailing whitespace client-side before submitting. Send the trimmed value to the API. | ||
| - Whitespace-only content in a required field counts as empty. | ||
| - Cap free-text `maxLength` to the backend column length via `inputOptions={{ maxLength: N }}` on `InputField`. The native input silently truncates paste. See [Forms](#forms) in the top-level rules. |
|
|
||
| #### Conditional / dependent validation | ||
|
|
||
| - Cross-field checks (e.g. password + confirmation match) run on blur of either field. The error attaches to the field that is invalid, not to both. |
| - The submit handler must guard against a second submission while one is in flight. Do not rely solely on the button being disabled. | ||
| - The Cancel button remains enabled during submission and closes the modal immediately. It does not abort the in-flight request; the request completes in the background. |
| - Form fields are disabled while a submission is in flight — the user cannot edit during the request. | ||
| - The submit handler must guard against a second submission while one is in flight. Do not rely solely on the button being disabled. | ||
| - The Cancel button remains enabled during submission and closes the modal immediately. It does not abort the in-flight request; the request completes in the background. | ||
| - On success, fire the success toast BEFORE navigation (see [Notifications](../../.claude/rules/fleet-frontend.md#notifications) and #48088) and close the modal. |
Issue
Docs-only. Kicks off the validation standardization workstream — target behavior for a forthcoming shared validation hook and per-form migrations.
Description
frontend/docs/patterns.md"Data validation" with 10 subsections: error timing, clearing, priority, submit button state, server-side errors, conditional validation, optional/disabled fields, input hygiene, in-flight lifecycle, visual affordances, and copy register..claude/rules/fleet-frontend.md.Screenrecording
Testing