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:
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([])
|
||||
})
|
||||
|
||||
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,
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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')
|
||||
|
||||
|
||||
Reference in new issue
Block a user