Skip to content

Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.

Accept comma as decimal separator in numeric inputs

Duarte Santos30fd3a84a1cd
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 537629f82..23bc34ffb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,11 @@
# Changelog
+## v1.2.1 — 2026-07-22
+
+- ⌨️ Weight and other numeric fields now accept a comma as decimal separator ("33,5") — iOS
+ decimal keyboards in many locales only offer a comma, which previously reset the field to 0.
+ Partial input like "33," no longer snaps to 0 while typing. (#13)
+
## v1.2.0 — 2026-07-21
Localization — the whole app now speaks your language. (#7)
diff --git a/frontend/package.json b/frontend/package.json
index 9af190893..1be143dca 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -1,7 +1,7 @@
{
"name": "opengym-frontend",
"private": true,
- "version": "1.1.1",
+ "version": "1.2.1",
"type": "module",
"scripts": {
"dev": "vite",
diff --git a/frontend/src/components/NumField.jsx b/frontend/src/components/NumField.jsx
new file mode 100644
index 000000000..6bdd63d26
--- /dev/null
+++ b/frontend/src/components/NumField.jsx
@@ -0,0 +1,31 @@
+import { useRef, useState } from 'react'
+
+// Numeric input that accepts "," as decimal separator — iOS decimal keypads in many
+// locales only offer a comma, and type="number" reports "" for it (value snaps to 0).
+// Keeps a local string draft while focused so partial input like "33," survives typing.
+export default function NumField({ value, onChange, decimal = true, ...rest }) {
+ const [draft, setDraft] = useState(null)
+ const committed = useRef(null)
+ // external change (e.g. −/+ buttons) while a draft is showing → drop the draft
+ if (draft !== null && committed.current !== value) { setDraft(null); committed.current = null }
+ const commit = raw => {
+ let s = raw.replace(/,/g, '.').replace(/[^0-9.]/g, '')
+ const i = s.indexOf('.')
+ if (i !== -1) s = decimal ? s.slice(0, i + 1) + s.slice(i + 1).replace(/\./g, '') : s.slice(0, i)
+ const n = s === '' || s === '.' ? 0 : Math.max(0, parseFloat(s))
+ committed.current = n
+ setDraft(s)
+ onChange(n)
+ }
+ return (
+ <input
+ type="text"
+ inputMode={decimal ? 'decimal' : 'numeric'}
+ value={draft ?? (value ?? '')}
+ onFocus={e => e.target.select()}
+ onChange={e => commit(e.target.value)}
+ onBlur={() => { setDraft(null); committed.current = null }}
+ {...rest}
+ />
+ )
+}
diff --git a/frontend/src/components/Stepper.jsx b/frontend/src/components/Stepper.jsx
index 9db809aad..2801f82fd 100644
--- a/frontend/src/components/Stepper.jsx
+++ b/frontend/src/components/Stepper.jsx
@@ -1,16 +1,12 @@
+import NumField from './NumField.jsx'
+
// Number field with −/+ buttons; tapping the field selects its content so typing replaces.
export default function Stepper({ value, step = 1, onChange, decimal = true, className = '', label }) {
const set = v => onChange(Math.max(0, Math.round((v || 0) * 100) / 100))
const inner = (
<div className={'step ' + className}>
<button onClick={() => set((+value || 0) - step)}>−</button>
- <input
- type="number"
- inputMode={decimal ? 'decimal' : 'numeric'}
- value={value}
- onFocus={e => e.target.select()}
- onChange={e => onChange(e.target.value === '' ? 0 : Math.max(0, parseFloat(e.target.value) || 0))}
- />
+ <NumField value={value} decimal={decimal} onChange={onChange} />
<button onClick={() => set((+value || 0) + step)}>+</button>
</div>
)
diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsx
index 2e3da0d70..de2b42210 100644
--- a/frontend/src/views/Workout.jsx
+++ b/frontend/src/views/Workout.jsx
@@ -8,6 +8,7 @@ import { fmtNum, fmtDate, todayISO, DAYN } from '../lib/format.js'
import { beep, vibrate } from '../lib/sound.js'
import { t } from '../lib/i18n.js'
import Media from '../components/Media.jsx'
+import NumField from '../components/NumField.jsx'
import { startFlow, exercisePicker, exConfigSheet, exerciseDetailSheet, topWeightSheet, finishWorkout, workoutCompleteSheet, confirmSheet } from '../sheets.jsx'
/* ---------- start chooser (no active workout) ---------- */
@@ -63,8 +64,7 @@ function ExerciseBlock({ entryIdx, compact, onToggle, onField, onBumpAll, onAddS
const cell = (s, i, col, cls) => (
<div className={'step ' + cls}>
<button onClick={() => onField(i, col.f, Math.max(0, Math.round(((s[col.f] || 0) - col.step) * 100) / 100))}>−</button>
- <input type="number" inputMode={col.dec ? 'decimal' : 'numeric'} value={s[col.f] ?? ''} onFocus={e => e.target.select()}
- onChange={e => onField(i, col.f, e.target.value === '' ? 0 : Math.max(0, (col.dec ? parseFloat(e.target.value) : Math.round(parseFloat(e.target.value))) || 0))} />
+ <NumField decimal={col.dec} value={s[col.f] ?? ''} onChange={v => onField(i, col.f, v)} />
<button onClick={() => onField(i, col.f, Math.max(0, Math.round(((s[col.f] || 0) + col.step) * 100) / 100))}>+</button>
</div>
)