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.

Progress photos: the before/after slider no longer runs backwards in Arabic

Duarte Santos8605441efdba
diff --git a/frontend/src/views/ProgressPhotos.compare.test.jsx b/frontend/src/views/ProgressPhotos.compare.test.jsx
new file mode 100644
index 000000000..8161c3be0
--- /dev/null
+++ b/frontend/src/views/ProgressPhotos.compare.test.jsx
@@ -0,0 +1,33 @@
+// @vitest-environment happy-dom
+import React, { act } from 'react'
+import { createRoot } from 'react-dom/client'
+import { afterEach, describe, expect, it } from 'vitest'
+import { useUI } from '../store/useUI.js'
+import { openProgressCompare } from './ProgressPhotos.jsx'
+
+globalThis.IS_REACT_ACT_ENVIRONMENT = true
+
+const photo = (d, n) => ({ d, m: { kind: 'image', hash: String(n).padStart(64, '0'), mime: 'image/jpeg' } })
+
+describe('before/after compare in a right-to-left language', () => {
+ let root, host
+ afterEach(() => {
+ act(() => root?.unmount())
+ host?.remove()
+ document.documentElement.removeAttribute('dir')
+ useUI.getState().closeAll()
+ })
+
+ it('keeps the stage left-to-right so the handle follows the finger and "before" sits on the before photo', () => {
+ document.documentElement.setAttribute('dir', 'rtl')
+ openProgressCompare(photo('2026-01-01', 1), photo('2026-03-01', 2))
+ const sheet = useUI.getState().sheets.at(-1)
+ host = document.createElement('div')
+ document.body.appendChild(host)
+ root = createRoot(host)
+ act(() => root.render(sheet.render(() => {})))
+ const stage = host.querySelector('.pp-compare')
+ expect(stage).not.toBeNull()
+ expect(stage.getAttribute('dir')).toBe('ltr')
+ })
+})
diff --git a/frontend/src/views/ProgressPhotos.jsx b/frontend/src/views/ProgressPhotos.jsx
index aebe00753..1015a1338 100644
--- a/frontend/src/views/ProgressPhotos.jsx
+++ b/frontend/src/views/ProgressPhotos.jsx
@@ -108,7 +108,9 @@ function ProgressCompare({ a, b, close }) {
<span className="mviewer-count">{days > 0 ? tn('{0} day apart', '{0} days apart', days) : t('Same day')}</span>
<span style={{ width: 36 }} />
</div>
- <div className="pp-compare" ref={stageRef} data-swipe-ignore
+ {/* A photo has no reading direction: before stays on the left and the finger drives the
+ handle the same way in Arabic, so the stage is ltr like DurationWheel's wheel. */}
+ <div className="pp-compare" dir="ltr" ref={stageRef} data-swipe-ignore
onPointerDown={onPointerDown} onPointerMove={onPointerMove} onPointerUp={endDrag} onPointerCancel={endDrag}>
{after.url && <img className="pp-img" src={after.url} alt="" draggable={false} />}
{before.url && <img className="pp-img" src={before.url} alt="" draggable={false}