Skip to content

Commit 1256331

Browse files
authored
fix(editor): guard onShelfMove against null cursorGroupRef (pascalorg#342)
Adds the missing `if (!cursorGroupRef.current) return` guard to onShelfMove. mitt listeners are registered for the tool's whole lifetime, so a shelf event can fire before the cursor group mounts or after teardown, leaving the ref null and throwing on `cursorGroupRef.current.rotation.y`. Partial fix for the EDITOR-BC family: the other placement handlers (onGridMove/onWallMove/onItemMove/onCeilingMove and the keyboard/cancel paths) share the same null-ref exposure and still need the broader, correctly-scoped guard — tracked separately (PR pascalorg#323 attempts this but needs rework).
1 parent c986ced commit 1256331

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

packages/editor/src/components/tools/item/use-placement-coordinator.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,6 +1147,9 @@ export function usePlacementCoordinator(config: PlacementCoordinatorConfig): Rea
11471147

11481148
const onShelfMove = (event: ShelfEvent) => {
11491149
has3DPointerDrivenMoveRef.current = true
1150+
// A shelf event can fire before the cursor group mounts or after
1151+
// teardown, leaving the ref null; bail before dereferencing it below.
1152+
if (!cursorGroupRef.current) return
11501153
const ctx = getContext()
11511154
if (ctx.state.surface !== 'shelf-surface') {
11521155
// Cursor entered via a move event without an enter — try

0 commit comments

Comments
 (0)