Skip to content

fix: guard WallTool grid handlers against null wallPreviewRef#392

Closed
anton-pascal wants to merge 1 commit into
mainfrom
fix/sentry-editor-BE
Closed

fix: guard WallTool grid handlers against null wallPreviewRef#392
anton-pascal wants to merge 1 commit into
mainfrom
fix/sentry-editor-BE

Conversation

@anton-pascal

Copy link
Copy Markdown
Contributor

Sentry: MONOREPO-EDITOR-BE (issue 7494188332)

TypeError: Cannot set properties of null (setting 'visible') in WallTool.

Root cause

onGridClick is subscribed to the mitt grid:click event. When the user switches tools mid-draft, the WallTool preview <mesh> unmounts and wallPreviewRef.current becomes null — but a queued grid:click event can still fire before the effect cleanup runs emitter.off. The state-1 branch then writes wallPreviewRef.current.visible = false on a null ref and throws.

Fix

Add if (!wallPreviewRef.current) return at the top of onGridClick, mirroring the guard onGridMove already has (if (!(cursorRef.current && wallPreviewRef.current)) return). stopDrafting already null-guards its wallPreviewRef.current.visible write (it's also called from onCancel), so no change needed there.

curve-tool.tsx was checked for the same pattern — its onGridClick doesn't touch a preview mesh ref, so no change needed.

Typecheck (tsc --build in packages/nodes): ✅ passes.

Precedent: same class of fix as "fix: guard onShelfMove against null cursorGroupRef (Sentry EDITOR-BC)".

@mintlify

mintlify Bot commented Jun 10, 2026

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
pascal 🔴 Failed Jun 10, 2026, 4:18 AM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@anton-pascal

Copy link
Copy Markdown
Contributor Author

Heads-up for review: this PR overlaps with #371 — both guard wallPreviewRef.current in wall/tool.tsx, created by the nightly Sentry triage on different nights (#371 on 6/04 targets the line-545 write path; this one targets onGridClick entry + stopDrafting). The guards are complementary, not conflicting, but they should be reviewed/merged together — or consolidated into one PR if preferred. Happy to consolidate on request.

@anton-pascal

Copy link
Copy Markdown
Contributor Author

Closing: superseded by #397 (merged aab48e0). The onGridClick entry + stopDrafting guards are covered by Aymeric's 04880d4 in the bug-sweep.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant