Skip to content

Improve routine validation and reorder exercises - #90

Merged
rd-code-23 merged 3 commits into
mainfrom
feature/routine-creation
Sep 12, 2026
Merged

rd-code-23 merged 3 commits into
mainfrom
feature/routine-creation

Conversation

@rd-code-23

@rd-code-23 rd-code-23 commented Sep 9, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • keep Save enabled while the routine draft is incomplete
  • validate the full draft when Save is clicked
  • show specific inline messages for a missing routine name and missing exercises
  • show a compact Complete required fields message only after an invalid Save attempt
  • reserve message space so the form does not shift
  • add pointer, touch, and keyboard exercise reordering with dnd kit
  • update React Hook Form with the final reordered array
  • rewrite exercise positions sequentially after every move
  • give each configured draft row a stable UI-only ID to prevent drag animation flicker
  • remove UI-only row IDs and exercise names before sending the create request

Validation behavior

Save is disabled only while the create request is running. Invalid drafts never reach the API because React Hook Form uses the shared Zod resolver before calling the mutation. The summary beneath Save is shown only when the latest Save attempt fails and is cleared when the user interacts with the form.

Reordering behavior

Each row uses a stable draftExerciseId for React and dnd kit identity. exerciseId cannot be used because the same exercise may be added multiple times, and position cannot be used because it changes during sorting. When dragging ends, the reordered array is stored in React Hook Form and positions are normalized to 0, 1, 2, and so on. draftExerciseId is browser-only and is stripped at the API boundary.

Verification

  • all 51 web tests pass
  • production web build passes
  • web typecheck passes
  • web lint passes
  • diff validation passes

@rd-code-23 rd-code-23 changed the title Show routine validation feedback on Save Improve routine validation and reorder exercises Sep 12, 2026
@rd-code-23
rd-code-23 merged commit 3210d0d into main Sep 12, 2026
1 check passed
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