From 5ab983213138dfc524f9fdd2788b93d71b112260 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Thu, 27 Aug 2026 08:13:30 +0200 Subject: [PATCH] fix(recipes): pre-selectionne la technique deja detectee dans le correcteur MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ouvrir le popover de correction depuis un highlight existant tombait sur la liste de choix (avec l'option "Aucune technique ici"), pas sur la vue metadonnees — pour voir/editer les ingredients/ustensiles deja rattaches a une technique correctement detectee, il fallait recliquer cette meme technique dans la liste, sans aucun indice que c'est ce qu'il fallait faire (rien ne la distingue des autres dans cette liste). Resultat cote utilisateur : la fonctionnalite de correction/edition de metadonnees etait techniquement presente mais invisible en pratique. TechStepCorrectionPopover demarre desormais selectionne sur `previousTechStepId` quand il est defini (un clic sur un highlight existant) — droit dans la vue Ingredients/Ustensiles, deja pre-remplie. "Changer" reste disponible pour rejoindre la liste complete (relabelliser ou supprimer la correspondance). Tests Cypress (component + e2e) mis a jour pour ce nouveau point d'entree par defaut. Co-Authored-By: Claude Sonnet 5 --- .../component/TechStepCorrectionPopover.cy.tsx | 11 +++++++++-- apps/web/cypress/e2e/recipes.ts | 7 ++++++- .../recipes/steps/TechStepCorrectionPopover.tsx | 12 +++++++++++- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/apps/web/cypress/component/TechStepCorrectionPopover.cy.tsx b/apps/web/cypress/component/TechStepCorrectionPopover.cy.tsx index 6c0cf07..08a4da2 100644 --- a/apps/web/cypress/component/TechStepCorrectionPopover.cy.tsx +++ b/apps/web/cypress/component/TechStepCorrectionPopover.cy.tsx @@ -103,8 +103,13 @@ describe("TechStepCorrectionPopover", () => { cy.wait("@getTechSteps"); cy.get(".tech-step-correction-popover__remove").should("not.exist"); + // An existing match starts pre-selected straight into the metadata view + // (see TechStepCorrectionPopover's own doc comment on why) — "Changer" + // reaches the pick list, where the remove option lives. cy.mount(); cy.wait("@getTechSteps"); + cy.get(".tech-step-correction-popover__remove").should("not.exist"); + cy.contains("button", "Changer").click(); cy.get(".tech-step-correction-popover__remove").should("exist"); }); @@ -199,9 +204,11 @@ describe("TechStepCorrectionPopover", () => { existingUtensils={[{ utensil: pan, start: 14, end: 23, source: "auto" }]} />, ); + // An existing match starts pre-selected on itself (see + // TechStepCorrectionPopover's own doc comment) — the metadata sections, + // pre-seeded from `existingIngredients`/`existingUtensils`, are visible + // immediately, no need to re-pick "Cuire" from a list first. cy.wait("@getTechSteps"); - - cy.contains(".tech-step-correction-popover__list button", "Mijoter").click(); cy.wait(["@getIngredients", "@getUnits", "@getUtensils"]); cy.contains(".tech-step-correction-popover__chip", "50 g Beurre").find("button").click(); diff --git a/apps/web/cypress/e2e/recipes.ts b/apps/web/cypress/e2e/recipes.ts index af0f2a9..3abd38b 100644 --- a/apps/web/cypress/e2e/recipes.ts +++ b/apps/web/cypress/e2e/recipes.ts @@ -114,8 +114,13 @@ Then("I should see the technique correction options", () => { // "Valider" click to actually submit (room was made for attaching // ingredient/utensil metadata first, see `TechStepCorrectionPopover.tsx`'s // own doc comment) — folded into this one step since nothing in this -// scenario cares about that intermediate state on its own. +// scenario cares about that intermediate state on its own. This step is +// only ever reached after clicking an *existing* highlight (see the +// previous step above), which now opens straight into that same +// technique's metadata view, not the pick list — "Changer" reaches the +// list this step actually needs to pick a different one from. When("I choose {string} as the correct technique", (label: string) => { + cy.contains("button", "Changer").click(); cy.contains(".tech-step-correction-popover__list button", label).click(); cy.contains(".tech-step-correction-popover__confirm-button", "Valider").click(); }); diff --git a/apps/web/src/features/recipes/steps/TechStepCorrectionPopover.tsx b/apps/web/src/features/recipes/steps/TechStepCorrectionPopover.tsx index 7493b46..ce24cf0 100644 --- a/apps/web/src/features/recipes/steps/TechStepCorrectionPopover.tsx +++ b/apps/web/src/features/recipes/steps/TechStepCorrectionPopover.tsx @@ -118,7 +118,17 @@ export function TechStepCorrectionPopover({ const { t } = useTranslation(); const popoverRef = useRef(null); const [techSteps, setTechSteps] = useState(null); - const [selectedTechStepId, setSelectedTechStepId] = useState(null); + // Opening this popover on an *already-detected* match (`previousTechStepId + // !== null`, i.e. the user clicked an existing highlight rather than + // selecting fresh text) starts pre-selected on that same technique — + // straight into the Ingrédients/Ustensiles view below, not the pick-a- + // technique list. Without this, editing an already-correct technique's + // metadata required re-picking that exact same technique from the list + // first, with nothing in the list marking it as the current one — the + // metadata sections were technically reachable but effectively + // undiscoverable. "Changer de technique" (below) still reaches the full + // list — to relabel, or to remove via the option only shown there. + const [selectedTechStepId, setSelectedTechStepId] = useState(previousTechStepId); const [catalogs, setCatalogs] = useState<{ ingredients: IngredientView[]; units: UnitView[];