fix(core): ignore stale form submit attempts#288
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds an internal attempt-tracking mechanism to ignore stale async validation results and submit rejections after a reset/canceled submit, and wires that mechanism through reset and submit flows; tests and changelog updated to reflect the behavior. Changes
Sequence Diagram(s)sequenceDiagram
participant User as User
participant UseForm as UseForm
participant SubmitAction as SubmitAction
participant AsyncValidation as AsyncValidation
participant FormState as FormState
User->>UseForm: trigger submit (attempt `#1`)
UseForm->>SubmitAction: start submit (records attempt `#1`)
SubmitAction->>AsyncValidation: run async validation
User->>UseForm: call reset (increments attempt -> `#2`)
UseForm->>FormState: clear submitting state / reset values
AsyncValidation-->>SubmitAction: late validation result (for `#1`)
SubmitAction->>SubmitAction: compare attempts (`#1` vs `#2`)
alt attempt is stale
SubmitAction->>FormState: ignore result (no updates)
else attempt is current
SubmitAction->>FormState: apply validation / continue submit
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~28 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Comment |
Summary
reset()cancels the in-flight submit lifecycle, not just the loading flagTesting
npm run buildnpm run lintnpm run typechecknode scripts/run-tests.mjs --filter "form.state"node scripts/run-tests.mjs --filter "form.async-validation"node scripts/run-tests.mjs --filter "useForm"Summary by CodeRabbit
Bug Fixes
Tests
Documentation