fix(structure): 表结构编辑器补充可拖拽的纵向滚动条 (#9585)
编辑表结构的「字段 / 索引」页签之前只有自绘的横向滚动条,纵向只能靠滚轮, 字段较多时既没有“还有更多内容”的视觉提示,也无法拖拽定位。 - 复用 useVerticalOverlayScrollbar 组合式函数,为当前激活的表格页签 (字段 / 索引)渲染与横向滚动条同款的覆盖式纵向滚动条; - 页签面板改为三行两列的 grid:工具栏、滚动区、横向条在第一列, 纵向条独占第二列,仅在有溢出且处于表格页签时出现; - 隐藏该滚动区残留的原生纵向滚动条,避免与自绘条重叠; - 补充单测:纵向滚动条在有溢出时出现、拖拽可同步 scrollTop, 以及非表格页签(DDL)下不渲染。 Fixes #9408 Co-authored-by: zipg <4047349+zipg@users.noreply.github.com>
This commit is contained in:
1 parent
0adef6e16a
commit
c71c35624b
4 files changed
+164
-15
No files matched your search
+49
@@ -837,6 +837,55 @@ describe("TableStructureEditor horizontal scrolling", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("TableStructureEditor vertical scrolling", () => {
|
||||
it("shows a fixed scrollbar for overflowing fields and syncs thumb dragging", async () => {
|
||||
const root = await mountEditor("postgres");
|
||||
const scroller = root.querySelector<HTMLElement>(".structure-table-scroller");
|
||||
if (!scroller) throw new Error("Missing structure table scroller");
|
||||
Object.defineProperties(scroller, {
|
||||
clientHeight: { configurable: true, value: 200 },
|
||||
scrollHeight: { configurable: true, value: 800 },
|
||||
scrollTop: { configurable: true, value: 0, writable: true },
|
||||
});
|
||||
|
||||
scroller.dispatchEvent(new Event("scroll"));
|
||||
await nextTick();
|
||||
await nextTick();
|
||||
|
||||
const track = root.querySelector<HTMLElement>(".structure-vertical-scrollbar");
|
||||
const thumb = root.querySelector<HTMLElement>(".structure-vertical-scrollbar__thumb");
|
||||
if (!track || !thumb) throw new Error("Missing fixed vertical scrollbar");
|
||||
expect(Number.parseFloat(thumb.style.height)).toBeCloseTo(25);
|
||||
expect(Number.parseFloat(thumb.style.top)).toBeCloseTo(0);
|
||||
|
||||
track.getBoundingClientRect = () => DOMRect.fromRect({ width: 10, height: 200 });
|
||||
document.body.style.userSelect = "text";
|
||||
track.dispatchEvent(new PointerEvent("pointerdown", { bubbles: true, button: 0, clientY: 50, isPrimary: true }));
|
||||
window.dispatchEvent(new PointerEvent("pointermove", { clientY: 125, isPrimary: true }));
|
||||
|
||||
expect(scroller.scrollTop).toBeCloseTo(400);
|
||||
expect(document.body.style.userSelect).toBe("none");
|
||||
window.dispatchEvent(new PointerEvent("pointerup", { isPrimary: true }));
|
||||
expect(document.body.style.userSelect).toBe("");
|
||||
});
|
||||
|
||||
it("does not render the vertical scrollbar when the editor opens on the DDL tab", async () => {
|
||||
const root = await mountLoadingEditor("ddl");
|
||||
const scroller = root.querySelector<HTMLElement>(".structure-table-scroller");
|
||||
if (!scroller) throw new Error("Missing structure table scroller");
|
||||
Object.defineProperties(scroller, {
|
||||
clientHeight: { configurable: true, value: 200 },
|
||||
scrollHeight: { configurable: true, value: 800 },
|
||||
});
|
||||
|
||||
scroller.dispatchEvent(new Event("scroll"));
|
||||
await nextTick();
|
||||
await nextTick();
|
||||
|
||||
expect(root.querySelector(".structure-vertical-scrollbar")).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("TableStructureEditor metadata loading", () => {
|
||||
it("opens the initial DDL tab with its always-visible table comment", async () => {
|
||||
const root = await mountLoadingEditor("ddl", "app_user", "Application users");
|
||||
|
||||
Reference in new issue
Block a user