Skip to content

fix(core): ignore synthetic mousemove events without coordinates in side menu - #2895

Merged
nperez0111 merged 1 commit into
TypeCellOS:mainfrom
himself65:fix/sidemenu-nonfinite-mouse-coords
Jul 16, 2026
Merged

fix(core): ignore synthetic mousemove events without coordinates in side menu#2895
nperez0111 merged 1 commit into
TypeCellOS:mainfrom
himself65:fix/sidemenu-nonfinite-mouse-coords

Conversation

@himself65

@himself65 himself65 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Problem

The side menu registers a document-level capture mousemove listener (SideMenuView.onMouseMove) that stores event.clientX/event.clientY verbatim. A synthetic mousemove created via new Event("mousemove") — e.g. dispatched by a browser extension — is a plain Event with no coordinate properties, so this.mousePos ends up as { x: undefined, y: undefined }. The coordinates then flow through Math.max(..., undefined)NaN into document.elementsFromPoint(), which throws:

TypeError: Failed to execute 'elementsFromPoint' on 'Document': The provided double value is non-finite.

Stack (from a production Sentry report, @blocknote/core 0.51.4, Chrome 150):

SideMenu.ts getBlockFromCoords → view.root.elementsFromPoint(coords.left, coords.top)
SideMenu.ts getBlockFromMousePos
SideMenu.ts updateStateFromMousePos
SideMenu.ts onMouseMove

Note this also crashes read-only editors: the editor.isEditable check in updateStateFromMousePos runs only after the coordinate lookup.

Fix

Early-return in onMouseMove when clientX/clientY are not finite numbers. Since this.mousePos can then never hold non-finite values, the deferred updateStateFromMousePos() call sites (scroll / doc update) are covered as well.

Testing

  • pnpm lint and tsgo --noEmit in packages/core — clean
  • pnpm test in packages/core — 458 passed, 3 skipped

Summary by CodeRabbit

  • Bug Fixes
    • Improved side menu stability by safely ignoring invalid or incomplete mouse movement events.
    • Prevented unnecessary editor hit-testing and state updates when pointer coordinates are unavailable.

…ide menu

A mousemove created via `new Event("mousemove")` (e.g. dispatched by a
browser extension) is a plain Event with no `clientX`/`clientY`. The
side menu's document-level listener stored the resulting `undefined`
coordinates, and `document.elementsFromPoint()` then threw
"TypeError: The provided double value is non-finite" in
`getBlockFromCoords` — including on read-only editors, since the
`isEditable` check only runs after the coordinate lookup.

Ignore mousemove events whose coordinates are not finite numbers.
@vercel

vercel Bot commented Jul 16, 2026

Copy link
Copy Markdown

@himself65 is attempting to deploy a commit to the TypeCell Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b5ee0406-2773-407a-b8f4-a427644059b9

📥 Commits

Reviewing files that changed from the base of the PR and between 4e9e785 and 88e8895.

📒 Files selected for processing (1)
  • packages/core/src/extensions/SideMenu/SideMenu.ts

📝 Walkthrough

Walkthrough

SideMenuView.onMouseMove now ignores synthetic or otherwise invalid mousemove events whose client coordinates are not finite, preventing downstream hit-testing from throwing.

Changes

Side menu event validation

Layer / File(s) Summary
Guard invalid mouse coordinates
packages/core/src/extensions/SideMenu/SideMenu.ts
onMouseMove returns early when clientX or clientY is not finite, before hit-testing and side menu state updates.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Suggested reviewers: yousefed

Poem

A bunny hops past coordinates unclear,
“No point to inspect when the numbers aren’t here!”
The side menu pauses, safe and spry,
While valid mouse moves go hopping by.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change in the side menu mousemove handling.
Description check ✅ Passed The description includes the problem, fix, and testing details, covering the main required PR information.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nperez0111 nperez0111 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @himself65

@nperez0111
nperez0111 merged commit a3a9801 into TypeCellOS:main Jul 16, 2026
1 of 3 checks passed
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.

2 participants