fix(editor): one focus marker on every handle, proven on an SVG vertex

This commit is contained in:
bchanot committed 2026-11-19 12:32:27 +01:00
1 parent 399a5adae6
commit e341f03390
5 files changed
+57 -11

No files matched your search

+50 -3
View File
@@ -573,10 +573,10 @@ const VIEWPORTS = [
{ width: 1280, height: 800 },
]
/** Enough annotations for the overview to grow the page well past one screen. */
const topBar = (page: Page) =>
page.locator('header:has([data-testid="topbar-account"])')
/** Enough annotations for the overview to grow the page well past one screen. */
const manyPoints = () =>
Array.from({ length: 14 }, (_, i) =>
pointOf(`pt-${i}`, 'main', { cx: 100 + i * 40, cy: 100, r: 10 }, `Pt ${i}`),
@@ -707,8 +707,13 @@ for (const viewport of VIEWPORTS) {
'focus on sticky chrome',
).toBe(before)
}
// A row hidden under the strip comes out below it, not under it.
const row = annotationList(page, dict).getByRole('button').nth(4)
// A row hidden under the strip comes out below it, not under it. The row sits low in the
// page: a short window lets the page scroll far enough to put it under the strip.
await page.setViewportSize({
width: page.viewportSize()!.width,
height: 400,
})
const row = annotationList(page, dict).getByRole('button').first()
await page.evaluate(
(el) => {
const top = el.getBoundingClientRect().top + window.scrollY
@@ -716,6 +721,11 @@ for (const viewport of VIEWPORTS) {
},
await row.elementHandle(),
)
const hidden = await stripGeometry(page)
expect(
(await row.boundingBox())!.y,
'precondition: the row starts under the strip',
).toBeLessThan(hidden.bottom)
await row.focus()
const now = await stripGeometry(page)
const top = (await row.boundingBox())!.y
@@ -724,6 +734,43 @@ for (const viewport of VIEWPORTS) {
)
})
test('a vertex handle (SVG) focused under the strip ends below it', async ({
page,
}) => {
await open(page, ...manyPoints(), {
...pointOf('zone-v', 'main', { cx: 0, cy: 0, r: 1 }, 'Zone V'),
kind: 'zone',
geometry: {
type: 'polygon',
points: [
[300, 200],
[600, 200],
[600, 500],
[300, 500],
],
},
})
await pickAnnotation(page, dict, 'Zone V')
const vertex = page.locator('[data-vertex="0"]')
await expect(vertex).toBeVisible()
await page.evaluate(() => {
const el = document.querySelector('[data-vertex="0"]')!
window.scrollTo(0, el.getBoundingClientRect().top + window.scrollY - 80)
})
const strip = await stripGeometry(page)
const before = (await vertex.boundingBox())!
expect(
before.y,
'precondition: the handle starts under the strip',
).toBeLessThan(strip.bottom)
await vertex.focus()
const after = (await vertex.boundingBox())!
expect(
after.y,
'the focused handle is below the strip',
).toBeGreaterThanOrEqual((await stripGeometry(page)).bottom)
})
test('with the strip hidden the scroll offset is not applied', async ({
page,
}) => {