From 32fc0071dc4f3c7636369907b1df177173a7b95c Mon Sep 17 00:00:00 2001 From: Duarte Santos Date: Tue, 21 Jul 2026 18:57:14 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20weight=20slider=20capped=20at=20a=20froze?= =?UTF-8?q?n=20=C2=B120kg=20window?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit WeightInput (used for body weight, goal weight, and per-exercise top weight) computed its slider's min/max once from the initial value and never revisited it — starting from a fresh 70kg default capped the slider at 90kg with no way to drag past it, exactly the reported bug. Widened the base window (±60) and made it self-extend when dragged or stepped to either edge, instead of getting stuck there. --- frontend/src/sheets.jsx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/frontend/src/sheets.jsx b/frontend/src/sheets.jsx index 90903e3..fb82423 100644 --- a/frontend/src/sheets.jsx +++ b/frontend/src/sheets.jsx @@ -46,19 +46,28 @@ export function loadStarterPlan() { /* ============================ weight picker (shared: body weight + goal) ============================ */ function WeightInput({ value, setValue, unit }) { const clamp = x => Math.max(20, Math.min(300, Math.round((x || 0) * 10) / 10)) + const HALF = 60 // slider window half-width — generous enough that most values never need to extend it const range = useRef(null) - if (!range.current) { const s = value || 70; range.current = [Math.max(30, Math.round(s - 20)), Math.min(250, Math.round(s + 20))] } + if (!range.current) { const s = value || 70; range.current = [Math.max(20, Math.round(s - HALF)), Math.min(300, Math.round(s + HALF))] } const [lo, hi] = range.current const sv = Math.max(lo, Math.min(hi, value)) const pct = ((sv - lo) / (hi - lo)) * 100 + // Dragging (or stepping) to either edge extends the window further instead of getting stuck + // there — the old fixed window (computed once, ±20) is exactly what capped the slider at ~90kg. + const onSlide = v => { + const n = clamp(v) + if (n <= lo && lo > 20) range.current = [Math.max(20, lo - HALF), hi] + if (n >= hi && hi < 300) range.current = [lo, Math.min(300, hi + HALF)] + setValue(n) + } return <>
- +
{fmtNum(value)} {unit}
- +
setValue(clamp(parseFloat(e.target.value)))} + onChange={e => onSlide(parseFloat(e.target.value))} style={{ '--track': `linear-gradient(90deg, var(--acc) ${pct}%, var(--bg2) ${pct}%)` }} /> }