From c7f0b7f84db20f24829a83f4a6b47524bf7340ee Mon Sep 17 00:00:00 2001 From: Jerald-Golden-B Date: Sat, 10 May 2025 17:56:02 +0530 Subject: [PATCH] Refactor drag control management: conditionally enable drag controls based on tool mode and ensure proper cleanup on unmount. --- app/src/modules/builder/groups/floorPlanGroup.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/modules/builder/groups/floorPlanGroup.tsx b/app/src/modules/builder/groups/floorPlanGroup.tsx index 28b6e6c..c1c38f0 100644 --- a/app/src/modules/builder/groups/floorPlanGroup.tsx +++ b/app/src/modules/builder/groups/floorPlanGroup.tsx @@ -31,7 +31,15 @@ const FloorPlanGroup = ({ floorPlanGroup, floorPlanGroupLine, floorPlanGroupPoin const { socket } = useSocketStore(); useEffect(() => { - addDragControl(dragPointControls, currentLayerPoint, state, floorPlanGroupPoint, floorPlanGroupLine, lines, onlyFloorlines, socket); + if (toolMode === 'move') { + addDragControl(dragPointControls, currentLayerPoint, state, floorPlanGroupPoint, floorPlanGroupLine, lines, onlyFloorlines, socket); + } + + return () => { + if (dragPointControls.current) { + dragPointControls.current.enabled = false; + } + }; }, [toolMode, state]); useEffect(() => {