Skip to content
This repository was archived by the owner on Jan 28, 2026. It is now read-only.

Commit d5deb48

Browse files
author
ge85riz
committed
🐛 fix: chairs did not use to move with a table when both were selected and rotated together. now they are properly updated.
1 parent 54bf424 commit d5deb48

1 file changed

Lines changed: 40 additions & 19 deletions

File tree

frontend/src/components/canvas/EventListeners.tsx

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -518,34 +518,55 @@ export const handleTransformEnd = (
518518
node.scaleX(1);
519519
node.scaleY(1);
520520

521+
// if chairs are rotated together with the table that they are attached to,
522+
// then we need this extra offset
523+
let chairSpecificExtraTableOffset = null;
524+
if (el.type === "chair" && el.attachedTo) {
525+
const tableNode = nodes.find(node => node.attrs.id === el.attachedTo);
526+
const table = state.elements.find(e => e.id === el.attachedTo)!;
527+
if (tableNode && table) {
528+
chairSpecificExtraTableOffset = { dx: tableNode?.x() - table.x!, dy: tableNode?.y() - table.y! };
529+
}
530+
531+
}
532+
521533
const update =
522-
el.type === "circleTable" || el.type === "chair"
523-
? {
534+
el.type === "circleTable" ? {
524535
id,
525536
radius: el.radius ? Math.max(10, el.radius * scaleX) : undefined,
526537
rotation: node.rotation(),
527538
x: node.x()!,
528539
y: node.y()!,
529-
}
530-
: el.type !== "wall" && el.type !== "arrow"
531-
? {
532-
id,
533-
x: node.x()!,
534-
y: node.y()!,
535-
width: el.width ? Math.max(10, el.width * scaleX) : undefined,
536-
height: el.height ? Math.max(10, el.height * scaleY) : undefined,
537-
rotation: node.rotation(),
538-
}
539-
: {
540+
} :
541+
el.type === "chair" ? {
540542
id,
543+
radius: el.radius ? Math.max(10, el.radius * scaleX) : undefined,
544+
rotation: node.rotation(), // Same rotation as table
541545
x: node.x(),
542546
y: node.y(),
543-
x1: el.x1! * scaleX,
544-
y1: el.y1! * scaleY,
545-
x2: el.x2! * scaleX,
546-
y2: el.y2! * scaleY,
547-
rotation: node.rotation(),
548-
};
547+
offset: {
548+
dx: el.offset!.dx! + (node.x() - el.x!) - (chairSpecificExtraTableOffset?.dx || 0), // Current relative position to table
549+
dy: el.offset!.dy! + (node.y() - el.y!) - (chairSpecificExtraTableOffset?.dy || 0), // Current relative position to table
550+
},
551+
} :
552+
el.type !== "wall" && el.type !== "arrow" ? {
553+
id,
554+
x: node.x()!,
555+
y: node.y()!,
556+
width: el.width ? Math.max(10, el.width * scaleX) : undefined,
557+
height: el.height ? Math.max(10, el.height * scaleY) : undefined,
558+
rotation: node.rotation(),
559+
} :
560+
{
561+
id,
562+
x: node.x(),
563+
y: node.y(),
564+
x1: el.x1! * scaleX,
565+
y1: el.y1! * scaleY,
566+
x2: el.x2! * scaleX,
567+
y2: el.y2! * scaleY,
568+
rotation: node.rotation(),
569+
};
549570
updates.push(update);
550571
}
551572

0 commit comments

Comments
 (0)