fix: restore centered turn navigation
This commit is contained in:
@@ -113,9 +113,14 @@ async function checkConsoleHistory(viewportHeight: number): Promise<void> {
|
|||||||
controlHeight: control.getBoundingClientRect().height,
|
controlHeight: control.getBoundingClientRect().height,
|
||||||
boundaryOffset: boundary.getBoundingClientRect().top - element.getBoundingClientRect().top + element.scrollTop,
|
boundaryOffset: boundary.getBoundingClientRect().top - element.getBoundingClientRect().top + element.scrollTop,
|
||||||
firstOffset: first.getBoundingClientRect().top - boundary.getBoundingClientRect().top,
|
firstOffset: first.getBoundingClientRect().top - boundary.getBoundingClientRect().top,
|
||||||
|
expectedOffset: Math.max(0, (element.getBoundingClientRect().height - element.children.length * 24) / 2),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
assertEquals(initialGeometry, { boundaryHeight: 24, controlHeight: 24, boundaryOffset: 0, firstOffset: 24 });
|
assertEquals(initialGeometry.boundaryHeight, 24);
|
||||||
|
assertEquals(initialGeometry.controlHeight, 24);
|
||||||
|
assertEquals(initialGeometry.firstOffset, 24);
|
||||||
|
assert(Math.abs(initialGeometry.boundaryOffset - initialGeometry.expectedOffset) <= 1,
|
||||||
|
"short turn lists must be vertically centered, with overflowing lists starting at the top");
|
||||||
assertEquals(await turnList.evaluate((element) => element.scrollHeight > element.clientHeight), viewportHeight === 340);
|
assertEquals(await turnList.evaluate((element) => element.scrollHeight > element.clientHeight), viewportHeight === 340);
|
||||||
const currentQuestionTop = await transcript
|
const currentQuestionTop = await transcript
|
||||||
.getByText("question 7", { exact: true })
|
.getByText("question 7", { exact: true })
|
||||||
@@ -202,11 +207,15 @@ async function checkConsoleHistory(viewportHeight: number): Promise<void> {
|
|||||||
element.dispatchEvent(new Event("scroll"));
|
element.dispatchEvent(new Event("scroll"));
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// A short list cannot scroll: older turns take their natural place above
|
// A short list cannot scroll: keep the whole compact list centered
|
||||||
// existing bars instead of adding blank space to force a fixed anchor.
|
// rather than adding artificial space to force a fixed anchor.
|
||||||
const firstOffset = await turnList.evaluate((element) =>
|
const centerOffset = await turnList.evaluate((element) => {
|
||||||
element.querySelector(".turn-button")!.getBoundingClientRect().top - element.getBoundingClientRect().top);
|
const first = element.firstElementChild!.getBoundingClientRect();
|
||||||
assertEquals(firstOffset, 24);
|
const last = element.lastElementChild!.getBoundingClientRect();
|
||||||
|
const viewport = element.getBoundingClientRect();
|
||||||
|
return (first.top + last.bottom - viewport.top - viewport.bottom) / 2;
|
||||||
|
});
|
||||||
|
assert(Math.abs(centerOffset) <= 1, "short lists must remain centered after prepending history");
|
||||||
await navigation.getByRole("button", { name: "Earlier conversation available" }).click();
|
await navigation.getByRole("button", { name: "Earlier conversation available" }).click();
|
||||||
}
|
}
|
||||||
await transcript.getByText("question 1", { exact: true }).waitFor();
|
await transcript.getByText("question 1", { exact: true }).waitFor();
|
||||||
@@ -255,6 +264,6 @@ async function checkConsoleHistory(viewportHeight: number): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const viewportHeight of [600, 400, 340]) {
|
for (const viewportHeight of [600, 400, 340]) {
|
||||||
Deno.test(`production Console keeps compact top-aligned turns and pages history at ${viewportHeight}px`,
|
Deno.test(`production Console keeps compact centered turns and pages history at ${viewportHeight}px`,
|
||||||
() => checkConsoleHistory(viewportHeight));
|
() => checkConsoleHistory(viewportHeight));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,6 +105,8 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
/* Center short lists; overflowing lists stay reachable from the top. */
|
||||||
|
justify-content: safe center;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
scrollbar-width: none;
|
scrollbar-width: none;
|
||||||
|
|||||||
Reference in New Issue
Block a user