Skip to content

fix: clear server-side field errors on edit (SDK-923)#2202

Draft
jeffredodd wants to merge 1 commit into
mainfrom
fix/SDK-923-clear-server-errors-on-edit
Draft

fix: clear server-side field errors on edit (SDK-923)#2202
jeffredodd wants to merge 1 commit into
mainfrom
fix/SDK-923-clear-server-errors-on-edit

Conversation

@jeffredodd

@jeffredodd jeffredodd commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

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 server fieldErrors onto RHF via setError(name, { type: 'custom', message }).
  • useField.handleChange never called clearErrors, and forms run mode: 'onSubmit', so RHF didn't reclear on change either. The custom error sat there forever.
  • Fix: in handleChange, when the field already has a type: 'custom' error, call clearErrors(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 — PaySchedule already 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)
  • Verified the new positive tests fail without the fix and pass with it (red → green); the negative test (client-side required error not cleared on edit) passes in both states, confirming the change is surgical.
  • Manual repro in sdk-app: open Pay Schedule, submit a date combination that trips a server validator, confirm the date error appears, edit the date, confirm the error clears, then resubmit successfully.
  • Spot-check a non-date field elsewhere (e.g., Compensation rate) to confirm the same clear-on-edit behavior across field types.

🤖 Generated with Claude Code


const handleChange = (updatedValue: TValue) => {
const value = transform ? transform(updatedValue) : updatedValue
if (fieldState.error?.type === 'custom') {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed errors are coming back as type custom from the server. Seems save if a user is indeed changing the input.

@jeffredodd jeffredodd marked this pull request as ready for review June 18, 2026 15:27
@jeffredodd jeffredodd requested a review from a team as a code owner June 18, 2026 15:27
@jeffredodd jeffredodd marked this pull request as draft June 24, 2026 16:29
@jeffredodd jeffredodd force-pushed the fix/SDK-923-clear-server-errors-on-edit branch from 04fb85d to 93ed3b5 Compare June 24, 2026 17:45
`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>
@jeffredodd jeffredodd force-pushed the fix/SDK-923-clear-server-errors-on-edit branch from 93ed3b5 to a39ef68 Compare June 24, 2026 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant