Файли
openidea/src/ui/dragCursor.test.ts
T
faysouтаfaysou fb56bd211b perf(ui): keep pane dividers responsive on large documents (#5506)
Grabbing a divider beside a large Markdown document changed the cursor on every element (an inherited cursor on the document, or the split group's own cursor rule), restyling the whole preview. A transparent fixed surface now holds the resize cursor during the drag, shared by split panes, docked tool windows and scrollbar drags. Visible and nearby Markdown blocks rewrap live; distant blocks keep their last width (clipped so the preview gains no horizontal overflow) until the drag ends, then reflow with the reading position preserved.

Co-authored-by: faysou <[email protected]>
2026-11-24 21:53:49 +08:00

43 рядки
1.3 KiB
TypeScript

import { afterEach, describe, expect, it } from "vitest";
import { lockDragCursor } from "./dragCursor";
const surfaces = () => [...document.querySelectorAll<HTMLElement>("[data-drag-cursor-surface]")];
const cursors = () => surfaces().map((el) => el.style.cursor);
afterEach(() => document.dispatchEvent(new Event("pointercancel")));
describe("lockDragCursor", () => {
it("holds the cursor until the drag ends", () => {
const release = lockDragCursor("col-resize");
expect(cursors()).toEqual(["col-resize"]);
release();
expect(cursors()).toEqual([]);
});
it("ignores a repeated release", () => {
const release = lockDragCursor("row-resize");
release();
release();
expect(cursors()).toEqual([]);
});
it("restores an outer drag after a nested one ends", () => {
const outer = lockDragCursor("col-resize");
const inner = lockDragCursor("nwse-resize");
expect(cursors()).toEqual(["col-resize", "nwse-resize"]);
inner();
expect(cursors()).toEqual(["col-resize"]);
outer();
expect(cursors()).toEqual([]);
});
it("releases when the pointer goes up outside the handle", () => {
lockDragCursor("col-resize");
document.dispatchEvent(new Event("pointerup", { bubbles: true }));
expect(cursors()).toEqual([]);
});
});