From 927537b3437101383e83bb5db6c2dc70ac80755e Mon Sep 17 00:00:00 2001 From: bchanot Date: Thu, 12 Nov 2026 15:16:34 +0100 Subject: [PATCH] fix(editor): keep the drawing still when the selection changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The « Sélection : … » tag above the drawing mounted on select and unmounted on deselect, moving the canvas. It is now sr-only text, not live, in both twins; board 04 deviation recorded (owner 2026-11-12). --- apps/app/e2e/shell/editor-deselect.spec.ts | 68 +++++++++++++++++++ apps/app/e2e/shell/editor-equine.spec.ts | 2 +- apps/app/e2e/support/editor.ts | 2 +- .../editor/annotations/SelectionTag.tsx | 13 ++-- .../unit/editor-annotations-tab.test.tsx | 9 +++ docs/design/README.md | 5 ++ 6 files changed, 91 insertions(+), 8 deletions(-) diff --git a/apps/app/e2e/shell/editor-deselect.spec.ts b/apps/app/e2e/shell/editor-deselect.spec.ts index 52d941f4..1cb52600 100644 --- a/apps/app/e2e/shell/editor-deselect.spec.ts +++ b/apps/app/e2e/shell/editor-deselect.spec.ts @@ -302,6 +302,28 @@ test.describe('deselect and D6b (editor, mouse and keyboard)', () => { expect(saves).toEqual([]) }) + test('the drawing does not move when the selection changes (no visible tag)', async ({ + page, + requests, + }) => { + const { actor } = await open(page) + requests.forbid(actor.account.email, actor.account.password) + const top = async () => (await box(page).boundingBox())!.y + const before = await top() + for (const [name, at] of [ + [POINT, { x: 700, y: 250 }], + [ZONE, { x: 175, y: 175 }], + [LINK, { x: 825, y: 575 }], + ] as [string, { x: number; y: number }][]) { + await clickAt(page, at) + await expectSelected(page, name) + await expect(selectionTag(page)).toHaveCSS('position', 'absolute') + expect(await top(), `${name} selected`).toBe(before) + await clickAt(page, IN_ROOT) + await expectDeselected(page) + expect(await top(), `${name} deselected`).toBe(before) + } + }) test('zoom, pan, marker drag and Ctrl+wheel keep the selection; a 2 px jitter on empty deselects', async ({ page, requests, @@ -751,6 +773,52 @@ test.describe('deselect and D6b (read-only twin at 375 px)', () => { expect(saves).toEqual([]) }) + test('the twin does not move when the selection changes (no visible tag)', async ({ + page, + context, + requests, + }) => { + const { actor } = await open(page, false) + requests.forbid(actor.account.email, actor.account.password) + await selectTab(page, dict, 'annotations') + const canvas = page.getByTestId('catalogue-canvas') + await expect(canvas).toBeVisible() + await canvas.scrollIntoViewIfNeeded() + const cdp = await context.newCDPSession(page) + const drawing = page + .getByTestId('catalogue-canvas-drawing') + .locator('svg') + .first() + const twinAt = (x: number, y: number) => + drawing.evaluate( + (svg, at) => { + const root = svg as unknown as SVGSVGElement + const p = root.createSVGPoint() + p.x = at.x + p.y = at.y + const m = p.matrixTransform(root.getScreenCTM()!) + return { x: m.x, y: m.y } + }, + { x, y }, + ) + const top = async () => (await canvas.boundingBox())!.y + const before = await top() + for (const [name, at] of [ + [POINT, { x: 700, y: 250 }], + [ZONE, { x: 175, y: 175 }], + [LINK, { x: 825, y: 575 }], + ] as [string, { x: number; y: number }][]) { + await tap(cdp, await twinAt(at.x, at.y)) + await expect(selectionTag(page)).toHaveCount(1) + await expect(selectionTag(page)).toContainText(name) + await expect(selectionTag(page)).toHaveCSS('position', 'absolute') + expect(await top(), `${name} selected`).toBe(before) + await tap(cdp, await twinAt(IN_RECT.x, IN_RECT.y)) + await expect(selectionTag(page)).toHaveCount(0) + expect(await top(), `${name} deselected`).toBe(before) + } + }) + test('Escape closes « Plus » first, then deselects the twin', async ({ page, context, diff --git a/apps/app/e2e/shell/editor-equine.spec.ts b/apps/app/e2e/shell/editor-equine.spec.ts index b1a73d4b..accf6e0a 100644 --- a/apps/app/e2e/shell/editor-equine.spec.ts +++ b/apps/app/e2e/shell/editor-equine.spec.ts @@ -320,7 +320,7 @@ test.describe('equine working copy and commit latency', () => { await expect(toolButton(page, dict, 'point')).toBeEnabled() await showDrawing(page, dict) await annotationList(page, dict).getByRole('button').first().click() - await expect(selectionTag(page)).toBeVisible() + await expect(selectionTag(page)).toHaveCount(1) // A horse path no annotation covers: its box centre hits the path itself. const at = await page .getByTestId('annotation-canvas') diff --git a/apps/app/e2e/support/editor.ts b/apps/app/e2e/support/editor.ts index 046b4bba..6edc1969 100644 --- a/apps/app/e2e/support/editor.ts +++ b/apps/app/e2e/support/editor.ts @@ -524,7 +524,7 @@ export const creationPanel = (page: Page) => export const annotationList = (page: Page, dict: Dict) => page.getByRole('list', { name: dict['editor.annotations.list'] }) -/** The tag over the drawing while an annotation is selected (the card is then hidden). */ +/** The screen-reader-only tag rendered while an annotation is selected. */ export const selectionTag = (page: Page) => page.getByTestId('annotation-selection-tag') diff --git a/apps/app/src/components/editor/annotations/SelectionTag.tsx b/apps/app/src/components/editor/annotations/SelectionTag.tsx index bb47a857..1cfcf21d 100644 --- a/apps/app/src/components/editor/annotations/SelectionTag.tsx +++ b/apps/app/src/components/editor/annotations/SelectionTag.tsx @@ -1,10 +1,11 @@ import { useT } from '@/i18n/useT' -const TAG = - 'pointer-events-none inline-block rounded-md px-2 py-1 text-xs ' + - 'bg-[var(--color-surface-strong)]' - -/** Board 04's tag over the drawing: « Sélection : « ». */ +/** + * « Sélection : « » for screen readers only. Out of the visual + * flow (sr-only is absolute): showing it shifted the drawing at each + * selection change (owner 2026-11-12). Sighted users read the highlight and + * the properties panel; not a live region, so nothing is announced twice. + */ export default function SelectionTag({ kind, name, @@ -14,7 +15,7 @@ export default function SelectionTag({ }) { const t = useT() return ( -

+

{t('editor.annotations.selection') .replace( '{kind}', diff --git a/apps/app/tests/unit/editor-annotations-tab.test.tsx b/apps/app/tests/unit/editor-annotations-tab.test.tsx index 91a973b6..0bc1492d 100644 --- a/apps/app/tests/unit/editor-annotations-tab.test.tsx +++ b/apps/app/tests/unit/editor-annotations-tab.test.tsx @@ -110,6 +110,15 @@ describe('selection and the list', () => { 'Sélection : point', ) }) + + it('keeps the selection tag out of the visual flow and not live', async () => { + await mount() + await selectFromList() + const tag = screen.getByTestId('annotation-selection-tag') + expect(tag).toHaveClass('sr-only') + expect(tag).not.toHaveAttribute('aria-live') + expect(tag).not.toHaveAttribute('role') + }) }) describe('a numeric edit', () => { diff --git a/docs/design/README.md b/docs/design/README.md index 0528c9f6..fb1220b1 100644 --- a/docs/design/README.md +++ b/docs/design/README.md @@ -106,6 +106,11 @@ Accepted deviations (owner 2026-11-02, V1-2.5): the boards stay as approved, not 2. On a phone, « Références » is a plain, non-collapsible card (`03`). Condition: it does not hide the anatomical area (it starts at or below the drawing's bottom, checked at 320 and 375 px). +Accepted deviation (owner 2026-11-12, brief « V1-2.6 — R1 — Dernier retour utilisateur »): board `04`'s +« Sélection : … » tag over the drawing is no longer shown, in the editor and its read-only twin. It was +redundant with the highlight and the side panel, and moved the drawing at each selection change. It stays in +the DOM as screen-reader-only text (`sr-only`, not a live region), so nothing is announced twice. + ## v1-2-6/ — V1-2.6 graphic editor maquettes (validated 2026-11-05) Validated by the owner on 2026-11-05 (brief « V1-2.6 — Validation UX définitive et préparation technique »: the