[form] Fix clearErrors dropping updates when multiple fields change at once - #5446
Conversation
commit: |
There was a problem hiding this comment.
Pull request overview
Fixes concurrent field error clearing in Base UI forms.
Changes:
- Uses functional state updates to prevent dropped error removals.
- Adds regression coverage for simultaneous field changes.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
packages/react/src/form/Form.tsx |
Safely composes concurrent error removals. |
packages/react/src/form/Form.test.tsx |
Tests clearing two errors in one commit. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Bundle size
PerformanceTotal duration: 1,362.51 ms +48.10 ms(+3.7%) | Renders: 76 (+0) | Paint: 2,123.23 ms +37.07 ms(+1.8%)
14 tests within noise — details Check out the code infra dashboard for more information about this PR. |
| return; | ||
| } | ||
| setErrors((previousErrors) => { | ||
| if (!previousErrors || !Object.hasOwn(previousErrors, name)) { |
There was a problem hiding this comment.
This fix ensures state consistency by moving error-clearing logic into a functional update, preventing stale state during batched updates when multiple fields change simultaneously.
Previous code referred to errors object which could become stale when react batch updates
✅ Deploy Preview for base-ui ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for base-ui ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
@claude review |
PR reviewThe core fix is correct: Bugs (1)1. ℹ️ The fix only holds when the
|
Issue reproduction
newslettererror survives when both should disappear