fix(editor): null-safe cursor-group access in placement coordinator (#323)

Guards every `cursorGroupRef.current` dereference in the placement coordinator against the null window where mitt listeners are live but the `<group>` is unmounted (mount/teardown race) — the EDITOR-BC/BD crash family.

`getContext()` falls back to the draft's rotation, so the validation/revalidate path (Shift keys, onKeyUp) is safe; only the cursor *writes* are guarded, so Escape/right-click cancel, Shift reset, leave-state cleanup and transition state still run unconditionally. Also guards `wallPreviewRef` inside `WallTool.stopDrafting()` (the double-click/cancel path that the earlier diff missed).

Reimplemented against current main (the original branch conflicted with #366 and used over-broad handler guards that silently dropped cancel/Shift). Verified: `tsc -p apps/editor` clean, biome clean on touched files.
This commit is contained in:
Anton
2026-06-03 15:54:21 -04:00
committed by GitHub
parent 98eeb1da90
commit cefcb013d9
2 changed files with 68 additions and 37 deletions
+3 -1
View File
@@ -431,7 +431,9 @@ export const WallTool: React.FC = () => {
const stopDrafting = () => {
buildingState.current = 0
wallPreviewRef.current.visible = false
if (wallPreviewRef.current) {
wallPreviewRef.current.visible = false
}
setDraftMeasurement(null)
}