fix(editor): guard onShelfMove against null cursorGroupRef (#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 #323 attempts this but needs rework).
This commit is contained in:
@@ -1147,6 +1147,9 @@ export function usePlacementCoordinator(config: PlacementCoordinatorConfig): Rea
|
|||||||
|
|
||||||
const onShelfMove = (event: ShelfEvent) => {
|
const onShelfMove = (event: ShelfEvent) => {
|
||||||
has3DPointerDrivenMoveRef.current = true
|
has3DPointerDrivenMoveRef.current = true
|
||||||
|
// A shelf event can fire before the cursor group mounts or after
|
||||||
|
// teardown, leaving the ref null; bail before dereferencing it below.
|
||||||
|
if (!cursorGroupRef.current) return
|
||||||
const ctx = getContext()
|
const ctx = getContext()
|
||||||
if (ctx.state.surface !== 'shelf-surface') {
|
if (ctx.state.surface !== 'shelf-surface') {
|
||||||
// Cursor entered via a move event without an enter — try
|
// Cursor entered via a move event without an enter — try
|
||||||
|
|||||||
Reference in New Issue
Block a user