fix(platform): unify form validation timing across all forms (#1943)#1970
fix(platform): unify form validation timing across all forms (#1943)#1970larryro wants to merge 2 commits into
Conversation
Forms validated on every keystroke (mode: 'onChange'), so a field showed an error on its first character before the user finished typing. Others used no mode (RHF's 'onSubmit' default), so timing was inconsistent app-wide. - Add a shared useForm wrapper (app/components/ui/forms/use-form.ts) that defaults mode to 'onTouched': validate after the first blur, then re-validate on change. Callers can still override mode explicitly. - Repoint every direct react-hook-form useForm call and useFormEditor to the wrapper and drop the ad-hoc mode: 'onChange' overrides. - Add an oxlint no-restricted-imports guard so future forms can't import useForm straight from react-hook-form and regress the timing. - Update component tests that asserted on-keystroke errors to blur first, and add a wrapper unit test covering the no-error-on-first-keystroke behaviour. Docs/i18n: N/A — no user-facing strings, message keys, or error wording changed; only validation timing.
|
Warning Review limit reached
More reviews will be available in 27 minutes and 38 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses rolling per-developer review limits. Reviews become available again as older review attempts age out of the rolling limit window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (46)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Desk Review — #1943 (unify form validation timing →
|
What & why
Closes #1943. Typing the first character into a field (e.g. "New password") immediately showed a validation error because most forms used
mode: 'onChange', while others used no mode at all (react-hook-form's'onSubmit'default) — validation timing was inconsistent app-wide.Changes
app/components/ui/forms/use-form.tsre-exportsuseFormwithmode: 'onTouched'as the default (validate after the first blur, then re-validate on change). A caller can still overridemodeexplicitly.react-hook-formuseFormcall sites anduseFormEditornow use the wrapper; the ad-hocmode: 'onChange'overrides are removed.no-restricted-importsrule blocks importinguseFormstraight fromreact-hook-form(with an exception for the wrapper itself), so future forms inherit the behaviour and can't regress.Acceptance criteria
mode: 'onChange'; the lint rule prevents new ones.Verification
bunx oxlint(platform) — cleanbunx tsc --noEmit(platform) — cleanbunx vitest --run --config vitest.ui.config.ts(platform UI suite, 337 files) — greenoxfmt --check— cleanDocs/i18n: N/A — no user-facing strings, message keys, or error wording changed; only validation timing.