diff --git a/frontend/app/components/Domain/Recipe/RecipeIngredientHtml.vue b/frontend/app/components/Domain/Recipe/RecipeIngredientHtml.vue index e89c08240..6c5d7f24d 100644 --- a/frontend/app/components/Domain/Recipe/RecipeIngredientHtml.vue +++ b/frontend/app/components/Domain/Recipe/RecipeIngredientHtml.vue @@ -17,14 +17,15 @@ import { useIngredientTextParser } from "~/composables/recipes"; interface Props { ingredient?: RecipeIngredient; scale?: number; + showZero?: boolean; } -const { ingredient, scale = 1 } = defineProps(); +const { ingredient, scale = 1, showZero = false } = defineProps(); const { useParsedIngredientText } = useIngredientTextParser(); const baseText = computed(() => { if (!ingredient) return ""; - const parsed = useParsedIngredientText(ingredient, scale); + const parsed = useParsedIngredientText(ingredient, scale, true, undefined, showZero); return [parsed.quantity, parsed.unit, parsed.name].filter(Boolean).join(" ").trim(); }); diff --git a/frontend/app/components/Domain/Recipe/RecipeIngredientListItem.vue b/frontend/app/components/Domain/Recipe/RecipeIngredientListItem.vue index f5773e053..76296b62e 100644 --- a/frontend/app/components/Domain/Recipe/RecipeIngredientListItem.vue +++ b/frontend/app/components/Domain/Recipe/RecipeIngredientListItem.vue @@ -45,10 +45,12 @@ interface Props { // off by default: the shopping list and the add-to-list dialog reuse this row, and a menu // button is noise in both. the recipe renderer opts in showSubstitutions?: boolean; + showZero?: boolean; } const props = withDefaults(defineProps(), { scale: 1, showSubstitutions: false, + showZero: false, }); const route = useRoute(); const auth = useMealieAuth(); @@ -56,7 +58,7 @@ const groupSlug = computed(() => route.params.groupSlug || auth.user?.value?.gro const { useParsedIngredientText } = useIngredientTextParser(); const parsedIng = computed(() => { - return useParsedIngredientText(props.ingredient, props.scale, true, groupSlug.value.toString()); + return useParsedIngredientText(props.ingredient, props.scale, true, groupSlug.value.toString(), props.showZero); }); diff --git a/frontend/app/components/Domain/Recipe/RecipeIngredients.test.ts b/frontend/app/components/Domain/Recipe/RecipeIngredients.test.ts index af9f734b4..0802e3299 100644 --- a/frontend/app/components/Domain/Recipe/RecipeIngredients.test.ts +++ b/frontend/app/components/Domain/Recipe/RecipeIngredients.test.ts @@ -98,4 +98,17 @@ describe("RecipeIngredients", () => { const labels = wrapper.findAll("input[type='checkbox']").map(input => input.attributes("aria-label")); expect(labels).toEqual(["2 cups flour", "salt to taste"]); }); + + test("tracks separate portions independently while keeping legacy references shared", async () => { + const first = mountIngredients([ingredients.curryPaste]); + await first.setProps({ portionKey: "step-a", portionReferenceIds: [ingredients.curryPaste.referenceId] }); + await first.find(".checkbox").trigger("click"); + const second = mountIngredients([ingredients.curryPaste]); + await second.setProps({ portionKey: "step-b", portionReferenceIds: [ingredients.curryPaste.referenceId] }); + expect(second.find(".checkbox").attributes("aria-pressed")).toBe("false"); + first.unmount(); + const restored = mountIngredients([ingredients.curryPaste]); + await restored.setProps({ portionKey: "step-a", portionReferenceIds: [ingredients.curryPaste.referenceId] }); + expect(restored.find(".checkbox").attributes("aria-pressed")).toBe("true"); + }); }); diff --git a/frontend/app/components/Domain/Recipe/RecipeIngredients.vue b/frontend/app/components/Domain/Recipe/RecipeIngredients.vue index 2f7328ca5..44a6648fc 100644 --- a/frontend/app/components/Domain/Recipe/RecipeIngredients.vue +++ b/frontend/app/components/Domain/Recipe/RecipeIngredients.vue @@ -32,7 +32,7 @@