fix: clear server-side field errors on edit (SDK-923)#2202
Draft
jeffredodd wants to merge 1 commit into
Draft
Conversation
jeffredodd
commented
Jun 18, 2026
|
|
||
| const handleChange = (updatedValue: TValue) => { | ||
| const value = transform ? transform(updatedValue) : updatedValue | ||
| if (fieldState.error?.type === 'custom') { |
Contributor
Author
There was a problem hiding this comment.
Confirmed errors are coming back as type custom from the server. Seems save if a user is indeed changing the input.
04fb85d to
93ed3b5
Compare
`SDKFormProvider` mirrors server `fieldErrors` onto the form via
`setError(name, { type: 'custom', ... })`. Without a clear-on-edit
behavior in this form, that error stays set until a full refresh,
blocking resubmission after the user corrects a date — the original
SDK-923 repro.
Subscribe to `formMethods.watch` inside `usePayScheduleForm` and clear
any `type: 'custom'` error on a field as soon as the user edits it.
RHF's values subject only fires for actual value changes (not blur),
so the subscription is narrow.
Client-side validation errors (`required`, `min`, zod-driven, etc.)
are untouched — the type filter only matches the server-error path.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
93ed3b5 to
a39ef68
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes SDK-923 — server-side validation errors on form fields blocked resubmission until a page refresh (reported on Pay Schedule date fields, but the bug is SDK-wide).
useSyncFieldErrors(SDKFormProvider) maps serverfieldErrorsonto RHF viasetError(name, { type: 'custom', message }).useField.handleChangenever calledclearErrors, and forms runmode: 'onSubmit', so RHF didn't reclear on change either. The custom error sat there forever.handleChange, when the field already has atype: 'custom'error, callclearErrors(name)before forwarding the new value. Client-side validation errors (required,min, zod-driven, etc.) are untouched — RHF's normal validation loop is unaffected.Despite the ticket framing, this was not a state-machine problem —
PaySchedulealready uses a robot3 machine. The bug was in the shared form layer, so the fix lives there and benefits every form, not just Pay Schedule.Test plan
npm run test -- --run src/components/Common/Fields/hooks/useField.test.tsx(22 pass; 3 new)npm run test -- --run src/partner-hook-utils/form/ src/components/Company/PaySchedule/(152 pass)npm run test -- --run src/components/Common/Fields/(51 pass)requirederror not cleared on edit) passes in both states, confirming the change is surgical.🤖 Generated with Claude Code