fix(editor): keep the drawing still when the selection changes

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).
This commit is contained in:
bchanot committed 2026-11-12 15:16:34 +01:00
1 parent 9f092ec1e2
commit 927537b343
6 files changed
+91 -8

No files matched your search

@@ -302,6 +302,28 @@ test.describe('deselect and D6b (editor, mouse and keyboard)', () => {
expect(saves).toEqual([]) 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 ({ test('zoom, pan, marker drag and Ctrl+wheel keep the selection; a 2 px jitter on empty deselects', async ({
page, page,
requests, requests,
@@ -751,6 +773,52 @@ test.describe('deselect and D6b (read-only twin at 375 px)', () => {
expect(saves).toEqual([]) 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 ({ test('Escape closes « Plus » first, then deselects the twin', async ({
page, page,
context, context,
+1 -1
View File
@@ -320,7 +320,7 @@ test.describe('equine working copy and commit latency', () => {
await expect(toolButton(page, dict, 'point')).toBeEnabled() await expect(toolButton(page, dict, 'point')).toBeEnabled()
await showDrawing(page, dict) await showDrawing(page, dict)
await annotationList(page, dict).getByRole('button').first().click() 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. // A horse path no annotation covers: its box centre hits the path itself.
const at = await page const at = await page
.getByTestId('annotation-canvas') .getByTestId('annotation-canvas')
+1 -1
View File
@@ -524,7 +524,7 @@ export const creationPanel = (page: Page) =>
export const annotationList = (page: Page, dict: Dict) => export const annotationList = (page: Page, dict: Dict) =>
page.getByRole('list', { name: dict['editor.annotations.list'] }) 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) => export const selectionTag = (page: Page) =>
page.getByTestId('annotation-selection-tag') page.getByTestId('annotation-selection-tag')
@@ -1,10 +1,11 @@
import { useT } from '@/i18n/useT' import { useT } from '@/i18n/useT'
const TAG = /**
'pointer-events-none inline-block rounded-md px-2 py-1 text-xs ' + * « Sélection : <type> « <nom> » for screen readers only. Out of the visual
'bg-[var(--color-surface-strong)]' * flow (sr-only is absolute): showing it shifted the drawing at each
* selection change (owner 2026-11-12). Sighted users read the highlight and
/** Board 04's tag over the drawing: « Sélection : <type> « <nom> ». */ * the properties panel; not a live region, so nothing is announced twice.
*/
export default function SelectionTag({ export default function SelectionTag({
kind, kind,
name, name,
@@ -14,7 +15,7 @@ export default function SelectionTag({
}) { }) {
const t = useT() const t = useT()
return ( return (
<p data-testid="annotation-selection-tag" className={TAG}> <p data-testid="annotation-selection-tag" className="sr-only">
{t('editor.annotations.selection') {t('editor.annotations.selection')
.replace( .replace(
'{kind}', '{kind}',
@@ -110,6 +110,15 @@ describe('selection and the list', () => {
'Sélection : point', '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', () => { describe('a numeric edit', () => {
+5
View File
@@ -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 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). 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) ## 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 Validated by the owner on 2026-11-05 (brief « V1-2.6 — Validation UX définitive et préparation technique »: the