Isolate block drag handles from selection and editing
Quality / quality (ubuntu-latest) (push) Failing after 10m0s
Quality / quality (windows-latest) (push) Canceled after 0s

This commit is contained in:
Clintchiz committed 2026-09-05 21:10:10 +05:30
1 parent 640dadaa75
commit 01c1aa567e
3 files changed
+15 -1

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@wrnexus/block-editor",
"version": "0.1.10",
"version": "0.1.11",
"type": "module",
"description": "Hydrated accessible editor runtime for WRNexus block documents.",
"exports": {
+4
View File
@@ -22,6 +22,10 @@ export function mountBlockCanvas(root: HTMLElement, tree: BlockNode, options: Mo
handle.setAttribute("aria-label", `Move ${node.type}`);
handle.style.touchAction = "none";
handle.textContent = "⋮⋮";
// Clicks must not bubble into selection or inline-edit handlers.
// Pointer/keyboard sensor events remain available to the DnD backend.
for (const name of ["click", "dblclick"])
handle.addEventListener(name, event => { event.preventDefault(); event.stopPropagation(); });
element.prepend(handle);
cleanup.push(() => handle.remove());
}
+10
View File
@@ -20,6 +20,16 @@ test("canvas annotates exact node locations and cleans editor decorations withou
expect(column.getAttribute("data-block-slot")).toBe("content");
expect(column.getAttribute("draggable")).toBe("false");
expect(root.querySelectorAll("[data-block-handle]")).toHaveLength(1);
const handle = root.querySelector("[data-block-handle]")!;
let clicks = 0, pointers = 0;
column.addEventListener("click", () => clicks++);
column.addEventListener("dblclick", () => clicks++);
column.addEventListener("pointerdown", () => pointers++);
handle.dispatchEvent(new window.MouseEvent("click", { bubbles: true }));
handle.dispatchEvent(new window.MouseEvent("dblclick", { bubbles: true }));
handle.dispatchEvent(new window.PointerEvent("pointerdown", { bubbles: true }));
expect(clicks).toBe(0);
expect(pointers).toBe(1);
expect(root.querySelector("[data-block-slot-target]")?.getAttribute("data-block-parent")).toBe("column");
expect(JSON.stringify(tree)).toBe(before);
mounted.destroy(); mounted.destroy();