feat(record-form): keep issues on their rows through list edits (PUI-126) #138

Open
pienter wants to merge 6 commits from feature/PUI-126-keep-issues-on-their-rows-through-list-edits into feature/PUI-125-recordform-hands-slot-fields-their-wiring
Owner

Issues now stay on their rows when list rows are added, removed or moved, so clearing on edit, the error summary and reveal all point at the row the message shows on.

Before: rows A, B, C, with issues on B and C. Remove A. The screen showed both messages correctly, but each issue still said "row 1" and "row 2". Fixing B's link (now row 0) cleared nothing, and fixing C's (row 1) cleared B's message.

Review guide

  • Repeater: update:modelValue gets a second argument, a ListChange { indexes } (old index → new, null for a removed row), for add, remove and move.
  • RecordFields: forwards it as field-change(path, change), including from nested rows and from a custom field:* slot's update(value, change?). A stray non-change argument is ignored.
  • utils/cms: new public clearIssuesAt(issues, path, change?).
    • Drops issues at the path and its parents, and below the path when there's no change (BlogForm tags).
    • With a change, renumbers the row issues in place (same objects, so nothing re-files and focus doesn't move) and drops a removed row's issues.
    • Returns issues itself when nothing changed.
  • useRecordForm: clearIssues is renamed clearIssuesAt and applies the helper. A function initial's result is copied too, and the copy is documented as a JSON copy.
  • Docs: AUDITs (record-form, repeater), docs/cms/forms-and-validation.md, CHANGELOG (all unreleased entries amended).

For you

  • D1 (interface): issue objects are changed in place. A caller's issue objects get a new path after a list edit. New objects would count as new issues: focus would jump and Repeater would re-file them.
  • D2 (interface): public ListChange and clearIssuesAt, and a second argument on Repeater's update:modelValue.
  • D3 (behaviour): a field-change on a list path without a change now drops that list's row issues. A row edit through a custom Repeater's row-slot update(patch) still clears the list's row issues, because no row path reaches the slot.

Proof

  • End-to-end tests (useRecordForm + RecordForm + list) cover the A/B/C remove case (B clears B; the summary shows only C), move, add, and row removal.
  • These fail when RecordFields stops forwarding the change. The custom-slot and duplicate-object tests fail without their fixes.
  • Test files run separately: issues 4, record-form-composable 20, record-form 3, repeater 32, reveal-field 32, read-only 21, access-forms 32.
  • bun run typecheck, lint and format pass. examples/vue type-check: only the known SettingsForm error (#136).
  • Not checked in a browser.

Review panel: changes + quality seats; their should-fix findings (a single public helper, reuse of containsPath, custom-slot forwarding, duplicate objects) are fixed in 6b1591a and 5d25332.

Choices made: renumberIssues kept private; duplicates matched by object identity without toRaw (utils/cms stays vue-free); Repeater computes the change (it knows the operation), RecordFields doesn't diff keys.

Merge after #137 (this PR is stacked on it).

Closes PUI-126

Issues now stay on their rows when list rows are added, removed or moved, so clearing on edit, the error summary and reveal all point at the row the message shows on. Before: rows A, B, C, with issues on B and C. Remove A. The screen showed both messages correctly, but each issue still said "row 1" and "row 2". Fixing B's link (now row 0) cleared nothing, and fixing C's (row 1) cleared B's message. **Review guide** - **Repeater:** `update:modelValue` gets a second argument, a `ListChange { indexes }` (old index → new, `null` for a removed row), for add, remove and move. - **RecordFields:** forwards it as `field-change(path, change)`, including from nested rows and from a custom `field:*` slot's `update(value, change?)`. A stray non-change argument is ignored. - **`utils/cms`:** new public `clearIssuesAt(issues, path, change?)`. - Drops issues at the path and its parents, and below the path when there's no change (BlogForm tags). - With a change, renumbers the row issues **in place** (same objects, so nothing re-files and focus doesn't move) and drops a removed row's issues. - Returns `issues` itself when nothing changed. - **`useRecordForm`:** `clearIssues` is renamed `clearIssuesAt` and applies the helper. A function `initial`'s result is copied too, and the copy is documented as a JSON copy. - **Docs:** AUDITs (record-form, repeater), `docs/cms/forms-and-validation.md`, CHANGELOG (all unreleased entries amended). **For you** - **D1 (interface): issue objects are changed in place.** A caller's issue objects get a new `path` after a list edit. New objects would count as new issues: focus would jump and Repeater would re-file them. - **D2 (interface): public `ListChange` and `clearIssuesAt`, and a second argument on Repeater's `update:modelValue`.** - **D3 (behaviour):** a `field-change` on a list path without a change now drops that list's row issues. A row edit through a custom Repeater's row-slot `update(patch)` still clears the list's row issues, because no row path reaches the slot. **Proof** - End-to-end tests (`useRecordForm` + RecordForm + list) cover the A/B/C remove case (B clears B; the summary shows only C), move, add, and row removal. - These fail when RecordFields stops forwarding the change. The custom-slot and duplicate-object tests fail without their fixes. - Test files run separately: issues 4, record-form-composable 20, record-form 3, repeater 32, reveal-field 32, read-only 21, access-forms 32. - `bun run typecheck`, lint and format pass. `examples/vue` type-check: only the known SettingsForm error (#136). - Not checked in a browser. **Review panel:** changes + quality seats; their should-fix findings (a single public helper, reuse of `containsPath`, custom-slot forwarding, duplicate objects) are fixed in 6b1591a and 5d25332. **Choices made:** `renumberIssues` kept private; duplicates matched by object identity without `toRaw` (`utils/cms` stays vue-free); Repeater computes the change (it knows the operation), RecordFields doesn't diff keys. Merge after #137 (this PR is stacked on it). Closes PUI-126
Repeater showed an issue on its row after a move or remove, but the
issue's path kept the index it arrived with, so clearing on edit, the
summary and reveal hit the wrong row. Repeater now reports a
`ListChange` (old index to new) with each add, remove and move;
RecordFields forwards it with `field-change`, and `useRecordForm`
renumbers the kept issues in place and drops a removed row's. The new
`renumberIssues` helper does the same for pages without the composable.

`clearIssues` is now `clearIssuesAt` and also drops issues below a
non-list field. A function `initial`'s result is copied too.

Refs PUI-126
Refs PUI-126
One public helper, `clearIssuesAt(issues, path, change?)`, now does the
clearing and renumbering that `useRecordForm` applies, so pages without
the composable call it instead of copying the rules. A custom `field:*`
slot's `update` forwards a list change, so a Repeater there renumbers
too. An issue object listed twice is renumbered once.

Refs PUI-126
docs(cms): use clearIssuesAt in the forms example
All checks were successful
ci / lint (pull_request) Successful in 28s
ci / typecheck (pull_request) Successful in 27s
ci / format (pull_request) Successful in 34s
ci / rust (pull_request) Successful in 4m2s
ci / release (pull_request) Has been skipped
5d25332bf2
Refs PUI-126
docs(record-form): record the issue renumbering under Unreleased
All checks were successful
ci / typecheck (pull_request) Successful in 28s
ci / lint (pull_request) Successful in 33s
ci / format (pull_request) Successful in 37s
ci / rust (pull_request) Successful in 2m49s
ci / release (pull_request) Has been skipped
e9f990cf6c
The 0.44.0 release stamped the Repeater, list-field and useRecordForm
entries this work had amended. 0.44.0 stays as released; the rename is
noted as breaking, with the rest under Changed and Added.

Refs PUI-126
Author
Owner

Needs you: D1–D3 in the body. Merge after #137. CI green; stacked on the updated #137 branch (merged in at 03af860). 0.44.0 released Repeater and useRecordForm, so the CHANGELOG now says it all under ## Unreleased (e9f990c): Breaking clearIssues → clearIssuesAt (with migration), Changed function initial copied, Added renumbering, ListChange and clearIssuesAt. The commits carry no !; under 0.x a breaking change counts as minor, the same as feat, so the version is unaffected. Review panel round 1: changes and quality seats; should-fix items fixed in 6b1591a and 5d25332. Test files run separately all pass; typecheck, lint and format pass; the only playground type error is the one #136 fixes. Not checked in a browser.

Needs you: D1–D3 in the body. Merge after #137. CI green; stacked on the updated #137 branch (merged in at 03af860). 0.44.0 released Repeater and useRecordForm, so the CHANGELOG now says it all under `## Unreleased` (e9f990c): **Breaking** `clearIssues` → `clearIssuesAt` (with migration), **Changed** function `initial` copied, **Added** renumbering, `ListChange` and `clearIssuesAt`. The commits carry no `!`; under 0.x a breaking change counts as minor, the same as `feat`, so the version is unaffected. Review panel round 1: changes and quality seats; should-fix items fixed in 6b1591a and 5d25332. Test files run separately all pass; typecheck, lint and format pass; the only playground type error is the one #136 fixes. Not checked in a browser.
All checks were successful
ci / typecheck (pull_request) Successful in 28s
ci / lint (pull_request) Successful in 33s
ci / format (pull_request) Successful in 37s
ci / rust (pull_request) Successful in 2m49s
ci / release (pull_request) Has been skipped
This pull request has changes conflicting with the target branch.
  • packages/ui/composables/useRecordForm.ts
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'feature/PUI-126-keep-issues-on-their-rows-through-list-edits:feature/PUI-126-keep-issues-on-their-rows-through-list-edits'
git switch 'feature/PUI-126-keep-issues-on-their-rows-through-list-edits'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'feature/PUI-125-recordform-hands-slot-fields-their-wiring'
git merge --no-ff 'feature/PUI-126-keep-issues-on-their-rows-through-list-edits'
git switch 'feature/PUI-126-keep-issues-on-their-rows-through-list-edits'
git rebase 'feature/PUI-125-recordform-hands-slot-fields-their-wiring'
git switch 'feature/PUI-125-recordform-hands-slot-fields-their-wiring'
git merge --ff-only 'feature/PUI-126-keep-issues-on-their-rows-through-list-edits'
git switch 'feature/PUI-126-keep-issues-on-their-rows-through-list-edits'
git rebase 'feature/PUI-125-recordform-hands-slot-fields-their-wiring'
git switch 'feature/PUI-125-recordform-hands-slot-fields-their-wiring'
git merge --no-ff 'feature/PUI-126-keep-issues-on-their-rows-through-list-edits'
git switch 'feature/PUI-125-recordform-hands-slot-fields-their-wiring'
git merge --squash 'feature/PUI-126-keep-issues-on-their-rows-through-list-edits'
git switch 'feature/PUI-125-recordform-hands-slot-fields-their-wiring'
git merge --ff-only 'feature/PUI-126-keep-issues-on-their-rows-through-list-edits'
git switch 'feature/PUI-125-recordform-hands-slot-fields-their-wiring'
git merge 'feature/PUI-126-keep-issues-on-their-rows-through-list-edits'
git push origin 'feature/PUI-125-recordform-hands-slot-fields-their-wiring'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
pienter/ui!138
No description provided.