Skip to content

Shopping list: Remove on a duplicated recipe removes the first copy, not the one clicked #645

Closed

Description

@LeMyst

What happens

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):

  1. Open a recipe that references another recipe, keep the reference ticked, Add to shopping list.
  2. Untick the reference, Add to shopping list again.
  3. 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:

if let Some(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

  1. added a commit that references this issue on Oct 9, 2026
    1878be4
  2. added a commit that references this issue on Oct 9, 2026
    da0da75
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions