You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Shopping list: Remove on a duplicated recipe removes the first copy, not the one clicked #645
When the same recipe is on the shopping list twice, Remove on the second entry removes the first one.
It is easy to see when the two entries differ — for instance a recipe with an optional sub-recipe reference, added once with the sub-recipe ticked and once without (or added at two different scales):
Open a recipe that references another recipe, keep the reference ticked, Add to shopping list.
Untick the reference, Add to shopping list again.
On the shopping list, click Remove on the second entry (the one without the sub-recipe).
Expected: the second entry goes away. Actual: the first entry (the one with the sub-recipe) is removed, and the one you clicked stays.
Why
The page only sends the entry's path:
body: JSON.stringify({ path })
and ShoppingListStore::remove (crates/core/src/shopping_list/store.rs:302) deletes the first entry whose path matches:
ifletSome(pos) = list.items.iter().position(|i| match i {ShoppingListItem::Recipe(r) => r.path == path,
_ => false,}){
list.items.remove(pos);}
First-match removal dates from e200582 ("feat: new UI" — // Remove only the first instance to allow removing individual entries). It was harmless while entries of the same recipe were interchangeable, but 7700032 (#318) kept it while giving each entry its own set of included sub-recipe references (and scale already differed), so entries with the same path are no longer equivalent and the wrong one is taken.
Proposed fix
Have the page say which entry it means: send its position in GET /api/shopping_list/items along with the path, and remove that entry only if its path still matches (answer 409 if the list changed in between rather than guess). Requests carrying only path keep today's behaviour, so other API clients are unaffected.
Activity
fix(server): remove the shopping list entry that was clicked
fix(server): remove the shopping list entry that was clicked (cooklan…