дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-09 19:25:54 +02:00
CodeMirror's tooltip container in `body` carries the editor's theme classes, so the themes' `height: 100%` gave it a full window of height. Scrolling to a position the editor had already reached then moved the page itself, leaving the title bar cut off and an empty band at the bottom. Set the height on `.cm-editor` only, and clip the body so nothing outside `#root` can make the page scrollable.
35 рядки
1.4 KiB
TypeScript
35 рядки
1.4 KiB
TypeScript
import { expect, openFromTree, test } from "./fixtures";
|
|
|
|
test("an open editor leaves nothing for the page itself to scroll", async ({ workbench: page }) => {
|
|
await openFromTree(page, "README.md");
|
|
const page_ = await page.evaluate(() => {
|
|
window.scrollBy(0, 100);
|
|
const root = document.documentElement;
|
|
return { scrollY: window.scrollY, scrollHeight: root.scrollHeight, clientHeight: root.clientHeight };
|
|
});
|
|
expect(page_.scrollY).toBe(0);
|
|
expect(page_.scrollHeight).toBe(page_.clientHeight);
|
|
});
|
|
|
|
test("scrolling to where the editor already is keeps the page in place", async ({ workbench: page }) => {
|
|
const editor = await openFromTree(page, "README.md");
|
|
await expect(editor.locator(".cm-content")).toBeVisible();
|
|
const scrollY = await page.evaluate(async () => {
|
|
const content = document.querySelector(".cm-content") as HTMLElement & {
|
|
cmTile?: { view: never };
|
|
cmView?: { view: never };
|
|
};
|
|
const view = (content.cmTile ?? content.cmView)!.view as {
|
|
constructor: { scrollIntoView(pos: number, options: { y: string }): unknown };
|
|
dispatch(spec: { effects: unknown }): void;
|
|
requestMeasure(): void;
|
|
};
|
|
for (let i = 0; i < 2; i++) {
|
|
view.dispatch({ effects: view.constructor.scrollIntoView(0, { y: "start" }) });
|
|
await new Promise((resolve) => requestAnimationFrame(() => setTimeout(resolve)));
|
|
}
|
|
return window.scrollY;
|
|
});
|
|
expect(scrollY).toBe(0);
|
|
});
|