feat(contracts): focus-first-invalid on the contract form via FormGuard (PMS-518) #355
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/PMS-518-migrate-contracts-form"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
PMS-518 increment: adds focus-first-invalid to the Create/Edit Contract form via
FormGuard.Context
This form already collects every field error at once (MAPPS-211: it sets each field's inline
*_errsignal and only returns at the end, never short-circuiting), so it already satisfies the "report all failures" half of the unified system. The one missing behaviour was focusing the first invalid field on a blocked submit.Change
On the failure path, builds a
FormGuardfrom the per-field err signals (read in field order), notes the first non-empty one, and focuses it viaguard.blocked(). The ids match each input'sname/DOM id. Line-item row errors have no single focusable id, so they fall back to no-focus (still blocked) when no top-level field is also invalid.Why not a full Rule rewrite
Deliberately keeps the bespoke typed validators (
validate_text_required/validate_money/validate_quantity/validate_text_optional): unlike the genericRuleset, they parse-and-return the typed values (Decimal,Option<String>, ...) the submit body consumes. Replacing them withRule::Numberetc. would force a re-parse and regress a form that already works well.FormGuardis adopted only for the focus/block behaviour.Verification
just checkparity via the rust-builder image:clippy --all-targets -- -D warnings,fmt --check,cargo check --target wasm32-unknown-unknown- all green.Scope: the contract create/edit form. The contracts modals (Contract Item, Rate Card, Rate Card Item, Allotted Hours) are further increments. Part of PMS-518.