Skip to content

fix: allow decimal weights in set inputs (e.g. 2.5 / 7.5) - #253

Open
luke-song wants to merge 1 commit into
Snouzy:mainfrom
luke-song:fix/decimal-weight-inputs
Open

luke-song wants to merge 1 commit into
Snouzy:mainfrom
luke-song:fix/decimal-weight-inputs

Conversation

@luke-song

Copy link
Copy Markdown

📝 Description

Weight inputs in workout sets (and admin suggested-set editors) previously used parseInt and pattern="[0-9]*", so values like 2.5 kg / 7.5 kg (and lb equivalents) could not be entered or kept.

This PR:

  • Widens valuesInt from Int[] → Float[] on WorkoutSet and ProgramSuggestedSet so fractional weights persist (existing integers cast cleanly)
  • Updates WEIGHT inputs to step="0.1", inputMode="decimal", and parseFloat (reps/time stay integers)
  • Removes the integer-only pattern on the session weight field so mobile keyboards allow decimals
  • Leaves display as the raw number value (no extra rounding that would drop .5)

Kept intentionally small and scoped to #99 only (no share-image / #54 / #252 work).

Note: Open PR #183 stores weights as ×10 “deci-units”, which would mis-display/mis-calculate existing integer weights and volume. This approach stores real decimals instead.

📋 Checklist

  • My code follows the project conventions
  • This PR includes breaking changes
  • I have updated documentation if necessary

🗃️ Prisma Migrations (if applicable)

  • I have created a migration
  • I have tested the migration locally

Migration: prisma/migrations/20260919000000_allow_decimal_weight_values — casts valuesInt to DOUBLE PRECISION[] on workout_sets and program_suggested_sets.

🧪 How to test

  1. Run migration (npx prisma migrate deploy / migrate dev) and regenerate client (prisma generate).
  2. Start a workout session → add a set with type WEIGHT.
  3. Enter 2.5, 7.5, 12.5 (kg or lbs) — value should stick after blur/finish set (not snap to 2 / 7 / 12).
  4. Complete/sync the session and reload — decimals should still be present.
  5. (Admin) Edit suggested sets / add exercise weight fields — same decimal entry works.
  6. Confirm REPS / TIME still behave as integers.

🔗 Related Issues

Fixes #99

Persist fractional kg/lb values by widening valuesInt to Float[], and update weight inputs to accept step 0.1 decimals without parseInt truncation.
@vercel

vercel Bot commented Sep 19, 2026

Copy link
Copy Markdown

@luke-song is attempting to deploy a commit to the Workoutcool Team Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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.

🤝 Help wanted: Allow decimal weights in inputs (e.g. 2.5 kg / 7.5 kg)

1 participant