From 29e2b44310ab71f30f915b1dcbfb2113c1659e41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Tue, 7 Jul 2026 10:36:45 +0200 Subject: [PATCH] fix(insights): stack the health-score delta caption below the delta line The v1.22 inline explainer caption rendered INSIDE the delta line's inline-flex row, so the short delta text ("-2 vs last week") wrapped into a narrow four-line column beside the multi-sentence read on every viewport. The wrapper now stacks: delta line with its trend icon on top, the caption below at full width. The aria-describedby thread from the delta digit to the caption id is unchanged. --- .../__tests__/health-score-card.test.tsx | 25 ++++++++ src/components/insights/health-score-card.tsx | 59 +++++++++++-------- 2 files changed, 60 insertions(+), 24 deletions(-) diff --git a/src/components/insights/__tests__/health-score-card.test.tsx b/src/components/insights/__tests__/health-score-card.test.tsx index ef0ee82e5..0353d7719 100644 --- a/src/components/insights/__tests__/health-score-card.test.tsx +++ b/src/components/insights/__tests__/health-score-card.test.tsx @@ -157,6 +157,31 @@ describe("", () => { ); }); + it("stacks the explainer caption BELOW the delta line, not beside it", () => { + // The caption is a multi-sentence read; rendering it inside the + // delta's inline-flex row squeezed the short delta into a narrow + // multi-line column on every viewport. The wrapper stacks instead. + const html = ssr( + , + ); + const wrapper = html.match( + /data-slot="health-score-card-delta"[^>]*class="([^"]*)"/, + ); + expect(wrapper).not.toBeNull(); + expect(wrapper?.[1]).toContain("space-y-1"); + expect(wrapper?.[1]).not.toContain("inline-flex"); + // The delta line's

closes before the explainer body opens — + // the caption is a sibling below, never a flex neighbour. + expect(html).toMatch( + /vs last week[^<]*<\/span><\/p>]*data-slot="health-score-delta-explainer-body"/, + ); + }); + it("renders four component rows with their values", () => { const html = ssr( {delta === null ? ( - {t("insights.healthScore.deltaUnavailable")} +

{t("insights.healthScore.deltaUnavailable")}

) : ( <> - {delta > 0 && ( -