diff --git a/frontend/pages/recipe/_slug/ingredient-parser.vue b/frontend/pages/recipe/_slug/ingredient-parser.vue index 30485aedb95b..45179efdbad4 100644 --- a/frontend/pages/recipe/_slug/ingredient-parser.vue +++ b/frontend/pages/recipe/_slug/ingredient-parser.vue @@ -140,6 +140,16 @@ export default defineComponent({ const { data } = await api.recipes.parseIngredients(parser.value, raw); if (data) { + // When we send the recipe ingredient text to be parsed, we lose the reference to the original unparsed ingredient. + // Generally this is fine, but if the unparsed ingredient had a title, we lose it; we add back the title for each ingredient here. + try { + for (let i = 0; i < recipe.value.recipeIngredient.length; i++) { + data[i].ingredient.title = recipe.value.recipeIngredient[i].title; + } + } catch (TypeError) { + console.error("Index Mismatch Error during recipe ingredient parsing; did the number of ingredients change?") + } + parsedIng.value = data; errors.value = data.map((ing, index: number) => {