fix(editor): one focus marker on every handle, proven on an SVG vertex
This commit is contained in:
1 parent
399a5adae6
commit
e341f03390
5 files changed
+57
-11
No files matched your search
@@ -573,10 +573,10 @@ const VIEWPORTS = [
|
|||||||
{ width: 1280, height: 800 },
|
{ width: 1280, height: 800 },
|
||||||
]
|
]
|
||||||
|
|
||||||
/** Enough annotations for the overview to grow the page well past one screen. */
|
|
||||||
const topBar = (page: Page) =>
|
const topBar = (page: Page) =>
|
||||||
page.locator('header:has([data-testid="topbar-account"])')
|
page.locator('header:has([data-testid="topbar-account"])')
|
||||||
|
|
||||||
|
/** Enough annotations for the overview to grow the page well past one screen. */
|
||||||
const manyPoints = () =>
|
const manyPoints = () =>
|
||||||
Array.from({ length: 14 }, (_, i) =>
|
Array.from({ length: 14 }, (_, i) =>
|
||||||
pointOf(`pt-${i}`, 'main', { cx: 100 + i * 40, cy: 100, r: 10 }, `Pt ${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',
|
'focus on sticky chrome',
|
||||||
).toBe(before)
|
).toBe(before)
|
||||||
}
|
}
|
||||||
// A row hidden under the strip comes out below it, not under it.
|
// A row hidden under the strip comes out below it, not under it. The row sits low in the
|
||||||
const row = annotationList(page, dict).getByRole('button').nth(4)
|
// 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(
|
await page.evaluate(
|
||||||
(el) => {
|
(el) => {
|
||||||
const top = el.getBoundingClientRect().top + window.scrollY
|
const top = el.getBoundingClientRect().top + window.scrollY
|
||||||
@@ -716,6 +721,11 @@ for (const viewport of VIEWPORTS) {
|
|||||||
},
|
},
|
||||||
await row.elementHandle(),
|
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()
|
await row.focus()
|
||||||
const now = await stripGeometry(page)
|
const now = await stripGeometry(page)
|
||||||
const top = (await row.boundingBox())!.y
|
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 ({
|
test('with the strip hidden the scroll offset is not applied', async ({
|
||||||
page,
|
page,
|
||||||
}) => {
|
}) => {
|
||||||
|
|||||||
@@ -169,6 +169,7 @@ function PointHandleShape({
|
|||||||
data-testid="point-handle"
|
data-testid="point-handle"
|
||||||
// Its arrow series commits on blur; the drawing guard sends it that blur (focus kept).
|
// Its arrow series commits on blur; the drawing guard sends it that blur (focus kept).
|
||||||
data-series=""
|
data-series=""
|
||||||
|
data-focus-target=""
|
||||||
className="group outline-none"
|
className="group outline-none"
|
||||||
onKeyDown={onKeyDown}
|
onKeyDown={onKeyDown}
|
||||||
onBlur={onBlur}
|
onBlur={onBlur}
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ function Insert({
|
|||||||
role="button"
|
role="button"
|
||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
aria-label={label}
|
aria-label={label}
|
||||||
|
data-focus-target=""
|
||||||
className="group outline-none"
|
className="group outline-none"
|
||||||
onKeyDown={onKeyDown}
|
onKeyDown={onKeyDown}
|
||||||
>
|
>
|
||||||
@@ -138,6 +139,7 @@ function Vertex({
|
|||||||
data-vertex={index}
|
data-vertex={index}
|
||||||
// Its arrow series commits on blur; the drawing guard sends it that blur (focus kept).
|
// Its arrow series commits on blur; the drawing guard sends it that blur (focus kept).
|
||||||
data-series=""
|
data-series=""
|
||||||
|
data-focus-target=""
|
||||||
className="group outline-none"
|
className="group outline-none"
|
||||||
onKeyDown={(event) => keys.onVertexKey(index, event)}
|
onKeyDown={(event) => keys.onVertexKey(index, event)}
|
||||||
onFocus={() => keys.onVertexFocus(index)}
|
onFocus={() => keys.onVertexFocus(index)}
|
||||||
@@ -204,6 +206,7 @@ function Remove({
|
|||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
aria-label={label}
|
aria-label={label}
|
||||||
aria-disabled={disabled}
|
aria-disabled={disabled}
|
||||||
|
data-focus-target=""
|
||||||
className="group outline-none"
|
className="group outline-none"
|
||||||
onKeyDown={onKeyDown}
|
onKeyDown={onKeyDown}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -20,12 +20,7 @@ body,
|
|||||||
shows, and the strip is sticky from 1 024 px only. */
|
shows, and the strip is sticky from 1 024 px only. */
|
||||||
@media (min-width: 1024px) {
|
@media (min-width: 1024px) {
|
||||||
[data-place='annotations.drawing']:not([hidden])
|
[data-place='annotations.drawing']:not([hidden])
|
||||||
:is(
|
:is([data-focus-key], [data-focus-target], [role='group'][tabindex='0']) {
|
||||||
[data-focus-key],
|
|
||||||
[data-vertex],
|
|
||||||
[data-testid='point-handle'],
|
|
||||||
[role='group'][tabindex='0']
|
|
||||||
) {
|
|
||||||
scroll-margin-top: calc(
|
scroll-margin-top: calc(
|
||||||
var(--shell-top-bar-height) + var(--edit-strip-height) + 1.5rem
|
var(--shell-top-bar-height) + var(--edit-strip-height) + 1.5rem
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -230,8 +230,8 @@ The edit strip (U2 Task 14) stays under the shell's top bar from 1 024 px: it is
|
|||||||
drawing, under the loupe, the menus, the bar and the dialogs), and no ancestor sets an
|
drawing, under the loupe, the menus, the bar and the dialogs), and no ancestor sets an
|
||||||
`overflow` other than visible. The bar's height (3.5 rem plus the safe-area inset) and the
|
`overflow` other than visible. The bar's height (3.5 rem plus the safe-area inset) and the
|
||||||
strip's (`--edit-strip-height`) are CSS variables of `styles/index.css`, which also feed a
|
strip's (`--edit-strip-height`) are CSS variables of `styles/index.css`, which also feed a
|
||||||
`scroll-margin-top` on the drawing place's focus targets (rows, vertex and point handles, the
|
`scroll-margin-top` on the drawing place's focus targets (rows, every focusable handle through
|
||||||
canvas box), from 1 024 px and only while the place is not `hidden`, so a focus or a
|
`data-focus-target`, the canvas box), from 1 024 px and only while the place is not `hidden`, so a focus or a
|
||||||
`scrollIntoView` never lands under either. It is a margin, not a page `scroll-padding`: the
|
`scrollIntoView` never lands under either. It is a margin, not a page `scroll-padding`: the
|
||||||
padding made the page jump when the focus went to the sticky bar or strip themselves.
|
padding made the page jump when the focus went to the sticky bar or strip themselves.
|
||||||
Below 1 024 px the strip is not sticky.
|
Below 1 024 px the strip is not sticky.
|
||||||
|
|||||||
Reference in new issue
Block a user