fix: keep equipment filter when changing muscle group in exercise picker

Selecting a body part after choosing an equipment type reset the
equipment filter to 'all equipment', even when the new muscle group
still had exercises for that equipment. The body-part chips called
setEq('') unconditionally.

Remove those resets from the per-body-part chips in the exercise picker
and the library. The existing eqOn fallback (eqOpts.includes(eq) ? eq : '')
already drops the filter for the current view when the new body part has
nothing under it, without discarding the user's choice. The 'All',
Favourites and Chosen chips still clear it, since they span every body part.

Fixes #71
This commit is contained in:
Sebastian G committed 2026-09-08 15:56:46 +02:00
1 parent 5c2005e81f
commit 4c21b647bc
2 files changed
+10 -3

No files matched your search

+6 -2
View File
@@ -901,11 +901,15 @@ function ExercisePicker({ onPick, close }) {
{showAll ? t('Filter by "{0}"', profile.name) : t('Show all equipment')}
</button>
</div>}
{/* Changing muscle group keeps the equipment filter: if it still has exercises under the new
group the filter stays applied, and if not the eqOn fallback above drops it for this view
without forgetting the choice (issue #71). The favourites/chosen chips still clear it —
those are cross-body-part views where a stale equipment filter would be confusing. */}
<div className="chips" ref={bpStrip} style={{ margin: eqOpts.length > 1 ? '10px 0 6px' : '10px 0' }}>
{favCount > 0 && <button className={'chip' + (bp === '☆' ? ' on' : '')} onClick={() => { setBp('☆'); setEq(''); setShown(50) }}><Icon name="starFill" className="fav-star" />{t('Favourites')} ({favCount})</button>}
{chosenCount > 0 && <button className={'chip' + (bp === '★' ? ' on' : '')} onClick={() => { setBp('★'); setEq(''); setShown(50) }}><Icon name="starFill" style={{ fontSize: 12, display: 'inline-block', marginRight: 4, verticalAlign: '-1px' }} />{t('Chosen')} ({chosenCount})</button>}
<button className={'chip nocap' + (!bp ? ' on' : '')} onClick={() => { setBp(''); setEq(''); setShown(50) }}>{t('All')}</button>
{BODYPARTS.map(b => <button key={b} className={'chip' + (bp === b ? ' on' : '')} onClick={() => { setBp(b); setEq(''); setShown(50) }}>{t(b)}</button>)}
<button className={'chip nocap' + (!bp ? ' on' : '')} onClick={() => { setBp(''); setShown(50) }}>{t('All')}</button>
{BODYPARTS.map(b => <button key={b} className={'chip' + (bp === b ? ' on' : '')} onClick={() => { setBp(b); setShown(50) }}>{t(b)}</button>)}
</div>
{eqOpts.length > 1 && <div className="chips" ref={eqStrip} style={{ marginBottom: 10 }}>
<button className={'chip nocap' + (!eqOn ? ' on' : '')} onClick={() => { setEq(''); setShown(50) }}>{t('Any equipment')}</button>
+4 -1
View File
@@ -46,9 +46,12 @@ export default function Library() {
{showAll ? t('Filter by "{0}"', profile.name) : t('Show all equipment')}
</button>
</div>}
{/* Changing body part keeps the equipment filter (issue #71): the eqOn fallback above drops
it only for the current view if the new body part has nothing under it, without forgetting
the choice. "All" clears it, since it spans every body part. */}
<div className="chips" ref={bpStrip} style={{ marginBottom: eqOpts.length > 1 ? 8 : 12 }}>
<button className={'chip nocap' + (!bp ? ' on' : '')} onClick={() => { setBp(''); setEq(''); setShown(40) }}>{t('All')}</button>
{BODYPARTS.map(b => <button key={b} className={'chip' + (bp === b ? ' on' : '')} onClick={() => { setBp(b); setEq(''); setShown(40) }}>{t(b)}</button>)}
{BODYPARTS.map(b => <button key={b} className={'chip' + (bp === b ? ' on' : '')} onClick={() => { setBp(b); setShown(40) }}>{t(b)}</button>)}
</div>
{eqOpts.length > 1 && <div className="chips" ref={eqStrip} style={{ marginBottom: 12 }}>
<button className={'chip nocap' + (!eqOn ? ' on' : '')} onClick={() => { setEq(''); setShown(40) }}>{t('Any equipment')}</button>