feat(forms): add field arrays, wizard flow, and disabled/readOnly controls#83
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a5f12e9b43
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for (let i = 0; i < currentValue.length; i++) { | ||
| dirty.push(!Object.is(currentValue[i], initialValue[i])); | ||
| } |
There was a problem hiding this comment.
Track array length changes when computing dirty state
computeArrayFieldDirty only compares indices up to currentValue.length, so shrinking an array with an unchanged prefix (for example ['a','b'] to ['a']) yields all-false dirty flags. Since computeIsDirty only looks for any true, the form can report isDirty === false even though values changed, which breaks unsaved-change detection for array fields.
Useful? React with 👍 / 👎.
| const step = getStep(currentStep); | ||
| const stepFields = getStepFields(step, state.values); | ||
| const stepErrors = runWizardStepValidation(state.values, currentStep, state); |
There was a problem hiding this comment.
Validate against latest step before advancing wizard
nextStep validates using the render-time currentStep/state.values snapshot, but the state update increments from prev.currentStep. If nextStep (or wizard-mode handleSubmit) is called twice before rerender, both validations run for the old step while both increments apply, so the wizard can skip intermediate-step validation gates.
Useful? React with 👍 / 👎.
|
Addressed the two review findings in
Validation rerun:
All passing. |
Summary
useFieldArraywithappend,remove, andmovedisabled/readOnlywith per-field overridesTests
form.fieldArray.test.tsform.wizard.test.tsform.disabled.test.tsnpm run lintnpm run buildnpm run typechecknode scripts/run-tests.mjs