From 74b1152774cbcec0f92156f35c2dfb2ab2dbf896 Mon Sep 17 00:00:00 2001 From: Sam Dornan Date: Tue, 15 Sep 2026 03:02:16 +0000 Subject: [PATCH] fix(frontend-v2): pin the recommendation caption to its cover's width Capping the caption at `--r-card-art-w` read the global 158px, but GameCard sets that token on itself, so the mobile override to 130px never reached the sibling caption: a long one widened the wrapper past the cover and threw the centring off. Pinning it the way GameCard pins its own label tracks whatever width the card resolves to, size variants included, and keeps the caption out of the row's scroll track. Also strengthens the Home caption test, which passed on the key alone and so missed a dropped interpolation value. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01427KQPf6WHJQ8feMKYp24Z --- .../shared/RecommendationReason.vue | 20 +++++++++---------- frontend/src/v2/utils/similarityReasons.ts | 4 ++-- frontend/src/v2/views/Home.test.ts | 11 +++++++--- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/frontend/src/v2/components/shared/RecommendationReason.vue b/frontend/src/v2/components/shared/RecommendationReason.vue index 71da11305..00ab1b70e 100644 --- a/frontend/src/v2/components/shared/RecommendationReason.vue +++ b/frontend/src/v2/components/shared/RecommendationReason.vue @@ -49,15 +49,16 @@ const caption = computed(() => { diff --git a/frontend/src/v2/utils/similarityReasons.ts b/frontend/src/v2/utils/similarityReasons.ts index b4a9420d9..fdd6c4f4d 100644 --- a/frontend/src/v2/utils/similarityReasons.ts +++ b/frontend/src/v2/utils/similarityReasons.ts @@ -30,8 +30,8 @@ const FACET_ICONS: Record = { const TRANSLATED_FACETS: Partial> = { igdb: "recommendations.reason-igdb", top_rated: "recommendations.reason-top-rated", - // Decades arrive as the starting year ("1990"); each locale suffixes it - // its own way, so the phrasing belongs in the locale files. + // Decades arrive as the starting year ("1990"), which each locale phrases + // in its own way, so the wording belongs in the locale files. decade: "recommendations.reason-decade", }; diff --git a/frontend/src/v2/views/Home.test.ts b/frontend/src/v2/views/Home.test.ts index 39d8113e7..a0bff14e8 100644 --- a/frontend/src/v2/views/Home.test.ts +++ b/frontend/src/v2/views/Home.test.ts @@ -10,7 +10,12 @@ import { useStreamingStore, type JoinableSession } from "@/stores/streaming"; import Home from "./Home.vue"; vi.mock("vue-i18n", () => ({ - useI18n: () => ({ t: (key: string) => key }), + useI18n: () => ({ + // Renders interpolated values alongside the key, so a caption that drops + // its parameter fails here instead of passing on the bare key. + t: (key: string, params?: unknown[]) => + [key, ...(params ?? [])].filter(Boolean).join(":"), + }), })); const { getLibraryInfo, getRecommendedRoms } = vi.hoisted(() => ({ @@ -245,8 +250,8 @@ describe("Home", () => { expect(getRecommendedRoms).toHaveBeenCalledTimes(1); const caption = wrapper.find(".rec-reason"); expect(caption.text()).toBe("Super Metroid"); - expect(caption.attributes("title")).toContain( - "recommendations.because-you-played", + expect(caption.attributes("title")).toBe( + "recommendations.because-you-played:Super Metroid", ); });