fix: 修复双击模式下单击对象失效,右键查看DDL、源码等复用右侧面板
This commit is contained in:
1 parent
f7f0397407
commit
3c4c16dc06
3 files changed
+36
-50
No files matched your search
@@ -94,9 +94,15 @@ describe("resolveRowClickAction", () => {
|
||||
});
|
||||
|
||||
describe("double-click activation mode", () => {
|
||||
it("single click (detail=1) returns none", () => {
|
||||
it("single click (detail=1) on TABLE returns table-info (side panel)", () => {
|
||||
const result = resolveRowClickAction(tableRow, 1, "double");
|
||||
expect(result.action).toBe("none");
|
||||
expect(result.action).toBe("table-info");
|
||||
expect(result.isDouble).toBe(false);
|
||||
});
|
||||
|
||||
it("single click (detail=1) on VIEW returns open-source (side panel)", () => {
|
||||
const result = resolveRowClickAction(viewRow, 1, "double");
|
||||
expect(result.action).toBe("open-source");
|
||||
expect(result.isDouble).toBe(false);
|
||||
});
|
||||
|
||||
@@ -118,28 +124,24 @@ describe("shouldDeferSingleClick", () => {
|
||||
const tableRow = row("TABLE", "users");
|
||||
const viewRow = row("VIEW", "v_users");
|
||||
|
||||
it("defers TABLE table-info in single mode (distinct single/double actions)", () => {
|
||||
expect(shouldDeferSingleClick(tableRow, "table-info", "single")).toBe(true);
|
||||
it("defers TABLE table-info (distinct single/double actions)", () => {
|
||||
expect(shouldDeferSingleClick(tableRow, "table-info")).toBe(true);
|
||||
});
|
||||
|
||||
it("does not defer VIEW open-source in single mode (same single/double action)", () => {
|
||||
expect(shouldDeferSingleClick(viewRow, "open-source", "single")).toBe(false);
|
||||
});
|
||||
|
||||
it("does not defer in double activation mode", () => {
|
||||
expect(shouldDeferSingleClick(tableRow, "table-info", "double")).toBe(false);
|
||||
it("does not defer VIEW open-source (same single/double action)", () => {
|
||||
expect(shouldDeferSingleClick(viewRow, "open-source")).toBe(false);
|
||||
});
|
||||
|
||||
it("does not defer none action", () => {
|
||||
expect(shouldDeferSingleClick(tableRow, "none", "single")).toBe(false);
|
||||
expect(shouldDeferSingleClick(tableRow, "none")).toBe(false);
|
||||
});
|
||||
|
||||
it("does not defer when action is not the single-click action", () => {
|
||||
expect(shouldDeferSingleClick(tableRow, "open-table", "single")).toBe(false);
|
||||
expect(shouldDeferSingleClick(tableRow, "open-table")).toBe(false);
|
||||
});
|
||||
|
||||
it("handles null/undefined row", () => {
|
||||
expect(shouldDeferSingleClick(null, "table-info", "single")).toBe(false);
|
||||
expect(shouldDeferSingleClick(undefined, "open-source", "single")).toBe(false);
|
||||
expect(shouldDeferSingleClick(null, "table-info")).toBe(false);
|
||||
expect(shouldDeferSingleClick(undefined, "open-source")).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -31,11 +31,17 @@ export function doubleClickRowAction(row: ObjectBrowserRow | null | undefined):
|
||||
/**
|
||||
* Resolve a row click event into a single or double action based on click detail
|
||||
* and the sidebar activation setting.
|
||||
*
|
||||
* In both single-click and double-click activation modes, a single click
|
||||
* triggers the side-panel action (table-info / open-source). When a distinct
|
||||
* double-click action exists (e.g. TABLE single→table-info, double→open-table),
|
||||
* the caller defers the single-click via shouldDeferSingleClick so the second
|
||||
* click can cancel it.
|
||||
*/
|
||||
export function resolveRowClickAction(row: ObjectBrowserRow | null | undefined, detail: number, activation: "single" | "double"): { action: ObjectBrowserRowAction; isDouble: boolean } {
|
||||
if (activation === "double") {
|
||||
if (detail === 2) return { action: doubleClickRowAction(row), isDouble: true };
|
||||
return { action: "none", isDouble: false };
|
||||
return { action: singleClickRowAction(row), isDouble: false };
|
||||
}
|
||||
// single-click activation
|
||||
if (detail > 1) return { action: doubleClickRowAction(row), isDouble: true };
|
||||
@@ -44,13 +50,12 @@ export function resolveRowClickAction(row: ObjectBrowserRow | null | undefined,
|
||||
|
||||
/**
|
||||
* Whether a single-click action should be deferred to distinguish it from a
|
||||
* possible upcoming double-click. Only applies in single-click activation mode
|
||||
* and when the row's single-click and double-click actions differ (e.g. TABLE:
|
||||
* single → table-info, double → open-table). For rows whose single and double
|
||||
* actions are identical (e.g. VIEW → open-source both), no deferral is needed.
|
||||
* possible upcoming double-click. Applies when the row's single-click and
|
||||
* double-click actions differ (e.g. TABLE: single → table-info, double →
|
||||
* open-table). For rows whose single and double actions are identical
|
||||
* (e.g. VIEW → open-source both), no deferral is needed.
|
||||
*/
|
||||
export function shouldDeferSingleClick(row: ObjectBrowserRow | null | undefined, action: ObjectBrowserRowAction, activation: "single" | "double"): boolean {
|
||||
if (activation !== "single") return false;
|
||||
export function shouldDeferSingleClick(row: ObjectBrowserRow | null | undefined, action: ObjectBrowserRowAction): boolean {
|
||||
if (action === "none") return false;
|
||||
const single = singleClickRowAction(row);
|
||||
const double = doubleClickRowAction(row);
|
||||
|
||||
Reference in new issue
Block a user