fix(editor): state the pinned column's window bounds; tidy its tests
The canvas is unchanged for browser windows of the three sizes, smaller in shorter ones; below 644 px of window height nothing is pinned (CSS comment, rendering doc, owner trial step 18). A page-top focus on the add row reveals it below the strip; the geometry helper is split, long test titles wrapped.
This commit is contained in:
1 parent
5e6d74428f
commit
031826dced
4 files changed
+90
-44
No files matched your search
@@ -608,38 +608,43 @@ function stripGeometry(page: Page) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The pinned drawing column (U2 Task 17): its box, the canvas box, what is painted at the
|
* The pinned drawing column (U2 Task 17): its box, the canvas box, what is painted at the
|
||||||
* canvas's top centre, and whether the page scrolls sideways.
|
* canvas's top centre.
|
||||||
*/
|
*/
|
||||||
function columnGeometry(page: Page) {
|
function columnGeometry(page: Page) {
|
||||||
return page.evaluate(() => {
|
return page.evaluate(() => {
|
||||||
const column = document.querySelector('[data-drawing-column]')!
|
const rect = (css: string) =>
|
||||||
const canvas = document.querySelector('[data-testid="annotation-canvas"]')!
|
document.querySelector(css)!.getBoundingClientRect()
|
||||||
const box = column.getBoundingClientRect()
|
const box = rect('[data-drawing-column]')
|
||||||
const drawing = canvas.getBoundingClientRect()
|
const drawing = rect('[data-testid="annotation-canvas"]')
|
||||||
const frame = document
|
|
||||||
.querySelector('[data-canvas-box]')!
|
|
||||||
.getBoundingClientRect()
|
|
||||||
const hit = document.elementFromPoint(
|
const hit = document.elementFromPoint(
|
||||||
drawing.x + drawing.width / 2,
|
drawing.x + drawing.width / 2,
|
||||||
drawing.y + 2,
|
drawing.y + 2,
|
||||||
)
|
)
|
||||||
// A sideways scroll attempt moves the page only if something overflows (scrollWidth
|
|
||||||
// against clientWidth hides up to the scrollbar gutter's width).
|
|
||||||
window.scrollTo(100, window.scrollY)
|
|
||||||
const sideways = window.scrollX > 0
|
|
||||||
window.scrollTo(0, window.scrollY)
|
|
||||||
return {
|
return {
|
||||||
top: box.top,
|
top: box.top,
|
||||||
bottom: box.bottom,
|
bottom: box.bottom,
|
||||||
canvas: { y: drawing.y, width: drawing.width, height: drawing.height },
|
canvas: { y: drawing.y, width: drawing.width, height: drawing.height },
|
||||||
canvasTopPainted: !!hit && canvas.contains(hit),
|
canvasTopPainted: !!hit?.closest('[data-testid="annotation-canvas"]'),
|
||||||
// Not capped: the canvas box still runs to the column's right edge.
|
// Not capped: the canvas box still runs to the column's right edge.
|
||||||
canvasFills: Math.abs(frame.right - box.right) < 0.5,
|
canvasFills: Math.abs(rect('[data-canvas-box]').right - box.right) < 0.5,
|
||||||
sideways,
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the page scrolls sideways: a scroll attempt moves it only if something overflows
|
||||||
|
* (scrollWidth against clientWidth hides up to the scrollbar gutter's width). It scrolls the
|
||||||
|
* page sideways and back, so it fires scroll events.
|
||||||
|
*/
|
||||||
|
function scrollsSideways(page: Page) {
|
||||||
|
return page.evaluate(() => {
|
||||||
|
window.scrollTo(100, window.scrollY)
|
||||||
|
const moved = window.scrollX > 0
|
||||||
|
window.scrollTo(0, window.scrollY)
|
||||||
|
return moved
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The focused element's top against the bottom of what covers it (the strip in the drawing
|
* The focused element's top against the bottom of what covers it (the strip in the drawing
|
||||||
* place, else the bar); null on the sticky chrome itself, whose focus never scrolls the page.
|
* place, else the bar); null on the sticky chrome itself, whose focus never scrolls the page.
|
||||||
@@ -844,7 +849,9 @@ for (const viewport of VIEWPORTS) {
|
|||||||
expect(pinned.canvas.height, `canvas height at ${at}`).toBe(
|
expect(pinned.canvas.height, `canvas height at ${at}`).toBe(
|
||||||
canvas.height,
|
canvas.height,
|
||||||
)
|
)
|
||||||
expect(pinned.sideways, `no sideways scroll at ${at}`).toBe(false)
|
expect(await scrollsSideways(page), `no sideways scroll at ${at}`).toBe(
|
||||||
|
false,
|
||||||
|
)
|
||||||
expect(pinned.canvasFills, `canvas not capped at ${at}`).toBe(true)
|
expect(pinned.canvasFills, `canvas not capped at ${at}`).toBe(true)
|
||||||
}
|
}
|
||||||
// Sticky leaves the flow alone: the aside keeps its place.
|
// Sticky leaves the flow alone: the aside keeps its place.
|
||||||
@@ -891,6 +898,22 @@ for (const viewport of VIEWPORTS) {
|
|||||||
)
|
)
|
||||||
await open(page, ...manyPoints(), big)
|
await open(page, ...manyPoints(), big)
|
||||||
await pickAnnotation(page, dict, 'Pt Big')
|
await pickAnnotation(page, dict, 'Pt Big')
|
||||||
|
// At the page top the add row is below the fold: its focus reveals it with the least
|
||||||
|
// scroll, never onto the bar or the strip, and the column stays below the strip.
|
||||||
|
await page.evaluate(() => window.scrollTo(0, 0))
|
||||||
|
const add = page.locator('[data-add-kind="point"]')
|
||||||
|
await add.focus()
|
||||||
|
const revealed = await stripGeometry(page)
|
||||||
|
const addBox = (await add.boundingBox())!
|
||||||
|
expect(addBox.y, 'the add button below the strip').toBeGreaterThanOrEqual(
|
||||||
|
revealed.bottom - 0.5,
|
||||||
|
)
|
||||||
|
expect(addBox.y + addBox.height).toBeLessThanOrEqual(
|
||||||
|
revealed.innerHeight + 0.5,
|
||||||
|
)
|
||||||
|
expect((await columnGeometry(page)).top).toBeGreaterThanOrEqual(
|
||||||
|
revealed.bottom - 0.5,
|
||||||
|
)
|
||||||
await page.evaluate(() => window.scrollTo(0, 300))
|
await page.evaluate(() => window.scrollTo(0, 300))
|
||||||
const before = (await stripGeometry(page)).scrollY
|
const before = (await stripGeometry(page)).scrollY
|
||||||
// The keyboard's focus move on the strip's command and on the bar's first control.
|
// The keyboard's focus move on the strip's command and on the bar's first control.
|
||||||
@@ -963,9 +986,10 @@ for (const viewport of VIEWPORTS) {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('a vertex handle (SVG) focused under the strip ends below it (window below the pinned height)', async ({
|
test(
|
||||||
page,
|
'a vertex handle (SVG) focused under the strip ends below it ' +
|
||||||
}) => {
|
'(window below the pinned height)',
|
||||||
|
async ({ page }) => {
|
||||||
await belowPinnedHeight(page)
|
await belowPinnedHeight(page)
|
||||||
await open(page, ...manyPoints(), {
|
await open(page, ...manyPoints(), {
|
||||||
...pointOf('zone-v', 'main', { cx: 0, cy: 0, r: 1 }, 'Zone V'),
|
...pointOf('zone-v', 'main', { cx: 0, cy: 0, r: 1 }, 'Zone V'),
|
||||||
@@ -985,7 +1009,10 @@ for (const viewport of VIEWPORTS) {
|
|||||||
await expect(vertex).toBeVisible()
|
await expect(vertex).toBeVisible()
|
||||||
await page.evaluate(() => {
|
await page.evaluate(() => {
|
||||||
const el = document.querySelector('[data-vertex="0"]')!
|
const el = document.querySelector('[data-vertex="0"]')!
|
||||||
window.scrollTo(0, el.getBoundingClientRect().top + window.scrollY - 80)
|
window.scrollTo(
|
||||||
|
0,
|
||||||
|
el.getBoundingClientRect().top + window.scrollY - 80,
|
||||||
|
)
|
||||||
})
|
})
|
||||||
const strip = await stripGeometry(page)
|
const strip = await stripGeometry(page)
|
||||||
const before = (await vertex.boundingBox())!
|
const before = (await vertex.boundingBox())!
|
||||||
@@ -999,11 +1026,13 @@ for (const viewport of VIEWPORTS) {
|
|||||||
after.y,
|
after.y,
|
||||||
'the focused handle is below the strip',
|
'the focused handle is below the strip',
|
||||||
).toBeGreaterThanOrEqual((await stripGeometry(page)).bottom)
|
).toBeGreaterThanOrEqual((await stripGeometry(page)).bottom)
|
||||||
})
|
},
|
||||||
|
)
|
||||||
|
|
||||||
test("Tab and Shift+Tab onto the drawing place's native controls land below the strip (window below the pinned height)", async ({
|
test(
|
||||||
page,
|
"Tab and Shift+Tab onto the drawing place's native controls land below the strip " +
|
||||||
}) => {
|
'(window below the pinned height)',
|
||||||
|
async ({ page }) => {
|
||||||
await belowPinnedHeight(page)
|
await belowPinnedHeight(page)
|
||||||
await open(page, ...manyPoints())
|
await open(page, ...manyPoints())
|
||||||
await pickAnnotation(page, dict, 'Pt 0')
|
await pickAnnotation(page, dict, 'Pt 0')
|
||||||
@@ -1033,11 +1062,13 @@ for (const viewport of VIEWPORTS) {
|
|||||||
).toBeGreaterThanOrEqual(at.limit - 0.5)
|
).toBeGreaterThanOrEqual(at.limit - 0.5)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
},
|
||||||
|
)
|
||||||
|
|
||||||
test('Delete from the keyboard focuses the next vertex below the strip (window below the pinned height)', async ({
|
test(
|
||||||
page,
|
'Delete from the keyboard focuses the next vertex below the strip ' +
|
||||||
}) => {
|
'(window below the pinned height)',
|
||||||
|
async ({ page }) => {
|
||||||
await belowPinnedHeight(page)
|
await belowPinnedHeight(page)
|
||||||
await open(page, ...manyPoints(), {
|
await open(page, ...manyPoints(), {
|
||||||
...pointOf('zone-k', 'main', { cx: 0, cy: 0, r: 1 }, 'Zone K'),
|
...pointOf('zone-k', 'main', { cx: 0, cy: 0, r: 1 }, 'Zone K'),
|
||||||
@@ -1075,11 +1106,13 @@ for (const viewport of VIEWPORTS) {
|
|||||||
expect(at.top, `${at.name} below the strip`).toBeGreaterThanOrEqual(
|
expect(at.top, `${at.name} below the strip`).toBeGreaterThanOrEqual(
|
||||||
(await stripGeometry(page)).bottom - 0.5,
|
(await stripGeometry(page)).bottom - 0.5,
|
||||||
)
|
)
|
||||||
})
|
},
|
||||||
|
)
|
||||||
|
|
||||||
test('pinned: Delete and Insert from the keyboard keep the page still, the vertex below the strip', async ({
|
test(
|
||||||
page,
|
'pinned: Delete and Insert from the keyboard keep the page still, ' +
|
||||||
}) => {
|
'the vertex below the strip',
|
||||||
|
async ({ page }) => {
|
||||||
await open(page, ...manyPoints(), {
|
await open(page, ...manyPoints(), {
|
||||||
...pointOf('zone-k', 'main', { cx: 0, cy: 0, r: 1 }, 'Zone K'),
|
...pointOf('zone-k', 'main', { cx: 0, cy: 0, r: 1 }, 'Zone K'),
|
||||||
kind: 'zone',
|
kind: 'zone',
|
||||||
@@ -1115,7 +1148,8 @@ for (const viewport of VIEWPORTS) {
|
|||||||
before,
|
before,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
})
|
},
|
||||||
|
)
|
||||||
|
|
||||||
test('pinned: a row selection moves neither the page nor the drawing on screen', async ({
|
test('pinned: a row selection moves neither the page nor the drawing on screen', async ({
|
||||||
page,
|
page,
|
||||||
@@ -1201,7 +1235,9 @@ for (const { pinned, ...viewport } of SHORT_WINDOWS) {
|
|||||||
const strip = await stripGeometry(page)
|
const strip = await stripGeometry(page)
|
||||||
const now = await columnGeometry(page)
|
const now = await columnGeometry(page)
|
||||||
const at = `scrollY ${strip.scrollY}`
|
const at = `scrollY ${strip.scrollY}`
|
||||||
expect(now.sideways, `no sideways scroll at ${at}`).toBe(false)
|
expect(await scrollsSideways(page), `no sideways scroll at ${at}`).toBe(
|
||||||
|
false,
|
||||||
|
)
|
||||||
expect(now.canvas.width, `canvas width at ${at}`).toBe(canvas.width)
|
expect(now.canvas.width, `canvas width at ${at}`).toBe(canvas.width)
|
||||||
if (!pinned) continue
|
if (!pinned) continue
|
||||||
expect(
|
expect(
|
||||||
|
|||||||
@@ -63,8 +63,8 @@ body,
|
|||||||
}
|
}
|
||||||
/* The drawing column (chips, tools, canvas, add row, message line) is pinned under the
|
/* The drawing column (chips, tools, canvas, add row, message line) is pinned under the
|
||||||
strip, so no part of the drawing is ever under it while the side panel scrolls (U2 Task
|
strip, so no part of the drawing is ever under it while the side panel scrolls (U2 Task
|
||||||
17). Only where the column fits: below 40.25rem high the 365 px tool column beside a
|
17). Only where the column fits: below 40.25rem (644 px) of window height the 365 px tool
|
||||||
capped canvas does not, and nothing here applies. The negative bottom margin lets the
|
column beside a capped canvas does not, nothing here applies and nothing is pinned. The negative bottom margin lets the
|
||||||
pinned travel run into the page's bottom space (workspace gap + main padding): without
|
pinned travel run into the page's bottom space (workspace gap + main padding): without
|
||||||
it, the page's end pushed the column's top under the strip at 1 180 x 820. */
|
it, the page's end pushed the column's top under the strip at 1 180 x 820. */
|
||||||
@media (min-width: 1024px) and (min-height: 40.25rem) {
|
@media (min-width: 1024px) and (min-height: 40.25rem) {
|
||||||
@@ -77,7 +77,9 @@ body,
|
|||||||
/* The column fits the window: the 4:3 box's width is capped by the small viewport height
|
/* The column fits the window: the 4:3 box's width is capped by the small viewport height
|
||||||
less the pinned top and the column's other parts (one row of chips, the add row, the
|
less the pinned top and the column's other parts (one row of chips, the add row, the
|
||||||
line, the gaps: 9.25rem), plus its 2 px border. svh: a toolbar collapsing during a
|
line, the gaps: 9.25rem), plus its 2 px border. svh: a toolbar collapsing during a
|
||||||
scroll never resizes the box. Unchanged at 1 024 x 768, 1 180 x 820, 1 280 x 800. */
|
scroll never resizes the box. Unchanged when the browser window (not the screen) is
|
||||||
|
1 024 x 768, 1 180 x 820 or 1 280 x 800; smaller in shorter windows (capped below
|
||||||
|
672, 789 and 672 px of window height). */
|
||||||
[data-drawing-column] [data-canvas-box] {
|
[data-drawing-column] [data-canvas-box] {
|
||||||
max-width: calc((100svh - var(--edit-pinned-top) - 9.25rem) * 4 / 3 + 2px);
|
max-width: calc((100svh - var(--edit-pinned-top) - 9.25rem) * 4 / 3 + 2px);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -255,13 +255,18 @@ always fits the window, the canvas box (`data-canvas-box`) is capped in width at
|
|||||||
`(100svh − --edit-pinned-top − 9.25 rem) × 4/3 + 2 px` (9.25 rem: one row of
|
`(100svh − --edit-pinned-top − 9.25 rem) × 4/3 + 2 px` (9.25 rem: one row of
|
||||||
chips, one add row, the line and the gaps; 2 px: the box's border), keeping its
|
chips, one add row, the line and the gaps; 2 px: the box's border), keeping its
|
||||||
4:3 ratio: the cap follows the window's small viewport height, never the
|
4:3 ratio: the cap follows the window's small viewport height, never the
|
||||||
scroll nor a collapsing browser toolbar, and leaves the box unchanged at
|
scroll nor a collapsing browser toolbar. The box is unchanged when the browser
|
||||||
1 024 × 768, 1 180 × 820 and 1 280 × 800; a capped box sits left, with spare
|
window (not the screen) is 1 024 × 768, 1 180 × 820 or 1 280 × 800, and smaller
|
||||||
width on its right. Its focusables carry only the bar's margin there (the
|
in shorter windows (capped below 672, 789 and 672 px of window height at those
|
||||||
|
widths; a tablet's browser toolbars take their height off the screen's); a
|
||||||
|
capped box sits left, with spare width on its right. The 9.25 rem assumes one
|
||||||
|
row of view chips: a sheet whose chips wrap to a second row makes the column
|
||||||
|
about 38 px taller than the cap allows, so where the cap binds the column's
|
||||||
|
top goes under the strip at the end of the page. Its focusables carry only the bar's margin there (the
|
||||||
strip's margin, larger than the pinned top, would scroll the page on a focus of
|
strip's margin, larger than the pinned top, would scroll the page on a focus of
|
||||||
a pinned control). Below 644 px high the tool column (365 px) no longer fits
|
a pinned control). Below 644 px of window height the tool column (365 px) no
|
||||||
beside a capped box: nothing is pinned or capped, and the drawing scrolls under
|
longer fits beside a capped box: nothing is pinned or capped, and the drawing
|
||||||
the strip as before, with the strip's margin on its focusables.
|
scrolls under the strip as before, with the strip's margin on its focusables.
|
||||||
|
|
||||||
The editor page's other focusables (criterion 25: the header's « Enregistrer », the
|
The editor page's other focusables (criterion 25: the header's « Enregistrer », the
|
||||||
tab row, « Défaire » and « Refaire », the notices' controls) carry a smaller margin,
|
tab row, « Défaire » and « Refaire », the notices' controls) carry a smaller margin,
|
||||||
|
|||||||
@@ -790,6 +790,9 @@ Tablette en paysage (au moins 1 024 px de large ; en dessous, l'éditeur est en
|
|||||||
18. Tablette et fenêtres de 1 024, 1 180 et 1 280 px : la bande qui reste en haut. Action : faites défiler la page
|
18. Tablette et fenêtres de 1 024, 1 180 et 1 280 px : la bande qui reste en haut. Action : faites défiler la page
|
||||||
avec une annotation sélectionnée. Attendu : la bande reste entière sous la barre du haut, rien ne bouge et rien
|
avec une annotation sélectionnée. Attendu : la bande reste entière sous la barre du haut, rien ne bouge et rien
|
||||||
n'est caché derrière. Un Tab sur une commande de la bande ou sur un lien de la barre ne fait pas défiler la page.
|
n'est caché derrière. Un Tab sur une commande de la bande ou sur un lien de la barre ne fait pas défiler la page.
|
||||||
|
Sur la tablette, faites défiler la page des annotations jusqu'à la fin : aucune partie du dessin, de ses boutons
|
||||||
|
de vue, de la rangée d'ajout ou de la ligne de message ne passe sous la bande. Si une partie y passe, notez-le :
|
||||||
|
la fenêtre fait alors moins de 644 px de haut.
|
||||||
19. Refaire retenu. Préparez quelque chose à défaire et à refaire : créez un point, déplacez-le d'un pas aux flèches
|
19. Refaire retenu. Préparez quelque chose à défaire et à refaire : créez un point, déplacez-le d'un pas aux flèches
|
||||||
validé par Entrée, puis « Défaire ». Action : outil « Zone », posez un sommet (la boîte de « Point » s'ouvre tout
|
validé par Entrée, puis « Défaire ». Action : outil « Zone », posez un sommet (la boîte de « Point » s'ouvre tout
|
||||||
de suite et cache l'en-tête : prenez « Zone »), puis donnez le focus à « Refaire » puis à « Défaire » : un lecteur
|
de suite et cache l'en-tête : prenez « Zone »), puis donnez le focus à « Refaire » puis à « Défaire » : un lecteur
|
||||||
|
|||||||
Reference in new issue
Block a user