From 251af2ce1d20e519ed660185908cbeafdff7918c Mon Sep 17 00:00:00 2001 From: open-pascal Date: Wed, 20 May 2026 00:57:15 +0000 Subject: [PATCH] fix: add null guards for cursorRef in fence and wall tool click handlers --- packages/nodes/src/fence/tool.tsx | 22 +--------------------- packages/nodes/src/wall/tool.tsx | 3 +-- 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/packages/nodes/src/fence/tool.tsx b/packages/nodes/src/fence/tool.tsx index 034d8e86..1353117c 100644 --- a/packages/nodes/src/fence/tool.tsx +++ b/packages/nodes/src/fence/tool.tsx @@ -509,27 +509,7 @@ export const FenceTool: React.FC = () => { const nextStart = createdFence.end startingPoint.current.set(nextStart[0], event.localPosition[1], nextStart[1]) endingPoint.current.copy(startingPoint.current) - cursorRef.current.position.copy(startingPoint.current) - previewRef.current.visible = false - buildingState.current = 1 - setDraftMeasurement(null) - } - } - - const onKeyDown = (e: KeyboardEvent) => { - if (e.key === 'Shift') shiftPressed.current = true - } - - const onKeyUp = (e: KeyboardEvent) => { - if (e.key === 'Shift') shiftPressed.current = false - } - - const onCancel = () => { - if (buildingState.current === 1) { - markToolCancelConsumed() - stopDrafting() - } - } + cursorRef.current?.position.copy(startingPoint.current) emitter.on('grid:move', onGridMove) emitter.on('grid:click', onGridClick) diff --git a/packages/nodes/src/wall/tool.tsx b/packages/nodes/src/wall/tool.tsx index 90c01aed..d9cd7285 100644 --- a/packages/nodes/src/wall/tool.tsx +++ b/packages/nodes/src/wall/tool.tsx @@ -481,8 +481,7 @@ export const WallTool: React.FC = () => { const nextStart = createdWall.end startingPoint.current.set(nextStart[0], event.localPosition[1], nextStart[1]) endingPoint.current.copy(startingPoint.current) - cursorRef.current.position.copy(startingPoint.current) - wallPreviewRef.current.visible = false + cursorRef.current?.position.copy(startingPoint.current) buildingState.current = 1 setDraftMeasurement(null) }