Fix shape dragging - allow drag from header elements

This commit is contained in:
Jeff Emmett 2026-01-02 14:32:02 +01:00
parent 36df10efe2
commit 7ebf45e984
1 changed files with 6 additions and 2 deletions

View File

@ -318,10 +318,14 @@ export class FolkShape extends FolkElement {
handle = focusedElement.getAttribute("part") as Handle | null;
}
// Check if target is a drag handle (header or element with data-drag attribute)
const isDragHandle = target?.closest?.(".header, [data-drag]") !== null;
if (event instanceof PointerEvent) {
event.stopPropagation();
if (event.type === "pointerdown") {
if (target !== this && !handle) return;
// Allow drag from: the host itself, a handle, or a drag handle element
if (target !== this && !handle && !isDragHandle) return;
if (handle?.startsWith("rotation")) {
const parentRotateOrigin = this.#rect.toParentSpace({
@ -373,7 +377,7 @@ export class FolkShape extends FolkElement {
if (!moveDelta) return;
if (target === this || (!handle && event instanceof KeyboardEvent)) {
if (target === this || isDragHandle || (!handle && event instanceof KeyboardEvent)) {
if (event instanceof KeyboardEvent && event.altKey) {
const ROTATION_MUL = event.shiftKey ? Math.PI / 12 : Math.PI / 36;
const rotationDelta = moveDelta.x !== 0 ? (moveDelta.x > 0 ? ROTATION_MUL : -ROTATION_MUL) : 0;