From 18110049f2468749f512d9c1108e361d75b9d546 Mon Sep 17 00:00:00 2001 From: Shinuwa Date: Fri, 23 Oct 2026 22:56:36 +0200 Subject: [PATCH] Keep Aniimo flip controls stable during card transitions --- e2e/aniimo.spec.js | 6 +++--- .../src/features/games/aniimo/AniimoCard.jsx | 18 ++---------------- website/src/styles/_aniimo.scss | 2 +- 3 files changed, 6 insertions(+), 20 deletions(-) diff --git a/e2e/aniimo.spec.js b/e2e/aniimo.spec.js index fe9ddb5..061c079 100644 --- a/e2e/aniimo.spec.js +++ b/e2e/aniimo.spec.js @@ -101,11 +101,11 @@ test("Aniimo matches MHW card motion, surfaces and filter controls", async ({ pa await expect(card).toBeVisible(); expect(await styles(card.locator(".aniimo-card-inner"), motionProperties)).toEqual(motion); expect(await styles(card.locator(".aniimo-front"), faceProperties)).toEqual(face); - expect(await styles(card.locator(".aniimo-front .aniimo-flip"), indicatorProperties)).toEqual(indicator); + expect(await styles(card.locator(".aniimo-card > .aniimo-flip"), indicatorProperties)).toEqual(indicator); expect(await styles(page.locator(".filter-logic").first(), filterProperties)).toEqual(filter); await page.keyboard.press("Escape"); - await expect(card.locator(".aniimo-face .aniimo-flip")).toHaveCount(2); - await expect(card.locator(".aniimo-card > .aniimo-flip")).toHaveCount(0); + await expect(card.locator(".aniimo-face .aniimo-flip")).toHaveCount(0); + await expect(card.locator(".aniimo-card > .aniimo-flip")).toHaveCount(1); await card.getByRole("button", { name: /Afficher les capacités/ }).press("Enter"); await expect(card.getByRole("button", { name: /Afficher le portrait/ })).toBeFocused(); await expect(card.locator(".aniimo-front")).toHaveAttribute("inert", ""); diff --git a/website/src/features/games/aniimo/AniimoCard.jsx b/website/src/features/games/aniimo/AniimoCard.jsx index 3539a78..2692baf 100644 --- a/website/src/features/games/aniimo/AniimoCard.jsx +++ b/website/src/features/games/aniimo/AniimoCard.jsx @@ -1,5 +1,5 @@ // Rôle : affiche une carte Aniimo retournable et les onglets des variantes correspondantes. -import { useId, useLayoutEffect, useRef, useState } from "react"; +import { useId, useState } from "react"; import { GuideChecklistCheckbox, GuideChecklistMark } from "../GuideChecklistControls.jsx"; import { Icon } from "../../../components/Icon.jsx"; import { Tooltip } from "../../../components/Tooltip.jsx"; @@ -18,24 +18,11 @@ function shortForm(label) { function CardFaces({ variant, t, content, checklist, statsMax }) { const completed = checklist.isCompleted(variant.key); const [flipped, setFlipped] = useState(false); - const frontButton = useRef(null); - const backButton = useRef(null); - const focusAfterFlip = useRef(false); - useLayoutEffect(() => { - if (!focusAfterFlip.current) return; - (flipped ? backButton : frontButton).current?.focus({ preventScroll: true }); - focusAfterFlip.current = false; - }, [flipped]); - function flip() { - focusAfterFlip.current = true; - setFlipped((value) => !value); - } - const flipButton = (back, ref) => ; return (
+
- {flipButton(false, frontButton)}
{t(variant.name)} N° {variant.aniimoId} @@ -48,7 +35,6 @@ function CardFaces({ variant, t, content, checklist, statsMax }) {
- {flipButton(true, backButton)}

{t(variant.name)}

diff --git a/website/src/styles/_aniimo.scss b/website/src/styles/_aniimo.scss index a965b4d..fe6e0d0 100644 --- a/website/src/styles/_aniimo.scss +++ b/website/src/styles/_aniimo.scss @@ -180,7 +180,7 @@ list-style: none; li { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; align-items: center; gap: 6px; font-size: var(--font-size-sm); } } -.aniimo-face .aniimo-flip { +.aniimo-card > .aniimo-flip { @include surfaces.flip-card-indicator; min-width: 0; min-height: 0;