Skip to content

Frontend: document form validation rules and error copy register#49041

Open
RachelElysia wants to merge 4 commits into
mainfrom
2026-07-validation
Open

Frontend: document form validation rules and error copy register#49041
RachelElysia wants to merge 4 commits into
mainfrom
2026-07-validation

Conversation

@RachelElysia

@RachelElysia RachelElysia commented Jul 9, 2026

Copy link
Copy Markdown
Member

Issue

Docs-only. Kicks off the validation standardization workstream — target behavior for a forthcoming shared validation hook and per-form migrations.

Description

  • Extends 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.
  • Adds rules under a new "Validation" section in .claude/rules/fleet-frontend.md.
  • Describes target behavior; upcoming work will be done for a shared validation hook that applies these new patterns as well as per-form migrations

Screenrecording

Testing

  • Reviewed markdown rendering on GitHub for both files
  • QA'd all new/changed functionality manually

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

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.11%. Comparing base (703dcf0) to head (e09a8d9).
⚠️ Report is 95 commits behind head on main.

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            
Flag Coverage Δ
frontend 59.29% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.
@RachelElysia RachelElysia marked this pull request as ready for review July 13, 2026 17:03
Copilot AI review requested due to automatic review settings July 13, 2026 17:03
Comment thread frontend/docs/patterns.md

- 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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementing this consistency in #49216

Copilot stopped reviewing on behalf of RachelElysia due to an error July 13, 2026 17:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.md form 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.md to 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.

Comment thread frontend/docs/patterns.md
Comment on lines +351 to +355
- 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.
Comment thread frontend/docs/patterns.md
- 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.
Comment thread frontend/docs/patterns.md

- 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.
Comment thread frontend/docs/patterns.md

#### 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.
Comment thread frontend/docs/patterns.md
Comment on lines +409 to +410
- 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.
Comment thread frontend/docs/patterns.md
- 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants