fix: Can't add first shopping list item to shopping list (#6013)

This commit is contained in:
Michael Genson
2025-08-25 11:53:36 -05:00
committed by GitHub
parent cac1699aeb
commit 347af7d417
3 changed files with 7 additions and 3 deletions

View File

@@ -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;