diff --git a/frontend/components/Domain/ShoppingList/ShoppingListItemEditor.vue b/frontend/components/Domain/ShoppingList/ShoppingListItemEditor.vue index e10a70332..0c67fc1ce 100644 --- a/frontend/components/Domain/ShoppingList/ShoppingListItemEditor.vue +++ b/frontend/components/Domain/ShoppingList/ShoppingListItemEditor.vue @@ -69,7 +69,7 @@ diff --git a/frontend/composables/shopping-list-page/sub-composables/use-shopping-list-crud.ts b/frontend/composables/shopping-list-page/sub-composables/use-shopping-list-crud.ts index 05911b81d..3d99bebeb 100644 --- a/frontend/composables/shopping-list-page/sub-composables/use-shopping-list-crud.ts +++ b/frontend/composables/shopping-list-page/sub-composables/use-shopping-list-crud.ts @@ -150,7 +150,10 @@ export function useShoppingListCrud( loadingCounter.value += 1; - // make sure it's inserted into the end of the list, which may have been updated + // ensure list id is set to the current list, which may not have loaded yet in the factory + createListItemData.value.shoppingListId = shoppingList.value.id; + + // ensure item is inserted into the end of the list, which may have been updated createListItemData.value.position = shoppingList.value?.listItems?.length ? (shoppingList.value.listItems.reduce((a, b) => (a.position || 0) > (b.position || 0) ? a : b).position || 0) + 1 : 0;