From fc15523c9f3fcf25b6f11166b3a9198a7a740f82 Mon Sep 17 00:00:00 2001 From: Harvey George Young Date: Tue, 19 Aug 2025 00:03:15 +0100 Subject: [PATCH] fix: Merge ingredient references when combining recipe steps in RecipePageInstructions.vue --- .../RecipePageParts/RecipePageInstructions.vue | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/frontend/components/Domain/Recipe/RecipePage/RecipePageParts/RecipePageInstructions.vue b/frontend/components/Domain/Recipe/RecipePage/RecipePageParts/RecipePageInstructions.vue index 2867b9d62..cc1f3d927 100644 --- a/frontend/components/Domain/Recipe/RecipePage/RecipePageParts/RecipePageInstructions.vue +++ b/frontend/components/Domain/Recipe/RecipePage/RecipePageParts/RecipePageInstructions.vue @@ -587,9 +587,22 @@ function mergeAbove(target: number, source: number) { source, targetText: instructionList.value[target].text, sourceText: instructionList.value[source].text, + targetIngredientReferences: [...(instructionList.value[target].ingredientReferences || [])], + sourceIngredientReferences: [...(instructionList.value[source].ingredientReferences || [])], }); instructionList.value[target].text += " " + instructionList.value[source].text; + + const targetRefs = instructionList.value[target].ingredientReferences || []; + const sourceRefs = instructionList.value[source].ingredientReferences || []; + const mergedRefsMap = new Map(); + [...targetRefs, ...sourceRefs].forEach(ref => { + if (ref.referenceId) { + mergedRefsMap.set(ref.referenceId, ref); + } + }); + instructionList.value[target].ingredientReferences = Array.from(mergedRefsMap.values()); + instructionList.value.splice(source, 1); }