Skip to content

fix(core): don't throw when the suggestion menu opens while not editable - #2978

Open
adarshsm wants to merge 1 commit into
TypeCellOS:mainfrom
adarshsm:fix/2701-suggestion-menu-uninitialized
Open

fix(core): don't throw when the suggestion menu opens while not editable#2978
adarshsm wants to merge 1 commit into
TypeCellOS:mainfrom
adarshsm:fix/2701-suggestion-menu-uninitialized

Conversation

@adarshsm

@adarshsm adarshsm commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Closes #2701

Problem

Toggling the editor to non-editable right as the suggestion (slash) menu opens — which a controlled editable prop can do under load — leaves SuggestionMenuView without a state, because the menu never gets shown. The stop / non-editable branch of update() then called emitUpdate unconditionally, which throws:

Error: Attempting to update uninitialized suggestions menu

Fix

Only hide the menu and emit an update when it actually has a state. If it was never shown there is nothing to update, so we return without calling emitUpdate.

Test

does not throw when the menu opens while not editable (#2701) sets editor.isEditable = false and then opens the suggestion menu, reproducing the crash deterministically. It throws on main and passes with this change.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed an error that could occur when opening a suggestion menu after the editor became non-editable.
    • Improved handling when a suggestion ends before its menu has been displayed.
  • Tests

    • Added regression coverage for suggestion menus without initialized state.

Toggling the editor to non-editable right as the suggestion menu opens (a
controlled `editable` prop can do this under load) leaves the menu view without
a `state`, because it never gets shown. The stop / non-editable branch of
`update()` then called `emitUpdate` unconditionally, which throws "Attempting
to update uninitialized suggestions menu" (TypeCellOS#2701).

Only hide and emit when the menu actually has a `state`; if it was never shown
there is nothing to update.
@vercel

vercel Bot commented Aug 16, 2026

Copy link
Copy Markdown

@adarshsm 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 Aug 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 Plus

Run ID: d7c5fa91-26a9-477a-abdf-b5d1179f603e

📥 Commits

Reviewing files that changed from the base of the PR and between ea5d803 and a43d8c0.

📒 Files selected for processing (2)
  • packages/core/src/extensions/SuggestionMenu/SuggestionMenu.test.ts
  • packages/core/src/extensions/SuggestionMenu/SuggestionMenu.ts

Included review availability: Your plan includes up to 10 reviews per rolling hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The suggestion menu now skips close updates when no menu state exists. A regression test verifies that opening the menu in a non-editable editor does not throw.

Changes

Suggestion menu fix

Layer / File(s) Summary
Guard uninitialized menu updates
packages/core/src/extensions/SuggestionMenu/SuggestionMenu.ts, packages/core/src/extensions/SuggestionMenu/SuggestionMenu.test.ts
SuggestionMenuView.update now hides and emits updates only when menu state exists. The test covers opening the menu in a non-editable editor without throwing.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to a43d8

The change narrowly prevents the suggestion menu from throwing when editability changes during opening, with a focused regression test covering the scenario; no actionable merge-blocking risk remains.

Suggested reviewers: matthewlipski

Poem

A rabbit found the menu asleep,
With no state tucked beneath its heap.
“No update now,” the rabbit said,
The editor stayed calm instead.
Slash marks danced without a fright.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the core fix: preventing a suggestion menu error when the editor is not editable.
Description check ✅ Passed The description explains the problem, rationale, fix, and regression test, but omits several template sections such as Impact and Checklist.
Linked Issues check ✅ Passed The change prevents the uninitialized suggestion menu error and adds a regression test for issue #2701.
Out of Scope Changes check ✅ Passed The implementation and regression test are limited to the suggestion menu crash described in issue #2701.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


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.

@pkg-pr-new

pkg-pr-new Bot commented Aug 16, 2026

Copy link
Copy Markdown

Open in StackBlitz

@blocknote/ariakit

npm i https://pkg.pr.new/@blocknote/ariakit@2978

@blocknote/code-block

npm i https://pkg.pr.new/@blocknote/code-block@2978

@blocknote/core

npm i https://pkg.pr.new/@blocknote/core@2978

@blocknote/diagram-block

npm i https://pkg.pr.new/@blocknote/diagram-block@2978

@blocknote/mantine

npm i https://pkg.pr.new/@blocknote/mantine@2978

@blocknote/math-block

npm i https://pkg.pr.new/@blocknote/math-block@2978

@blocknote/react

npm i https://pkg.pr.new/@blocknote/react@2978

@blocknote/server-util

npm i https://pkg.pr.new/@blocknote/server-util@2978

@blocknote/shadcn

npm i https://pkg.pr.new/@blocknote/shadcn@2978

@blocknote/xl-ai

npm i https://pkg.pr.new/@blocknote/xl-ai@2978

@blocknote/xl-docx-exporter

npm i https://pkg.pr.new/@blocknote/xl-docx-exporter@2978

@blocknote/xl-email-exporter

npm i https://pkg.pr.new/@blocknote/xl-email-exporter@2978

@blocknote/xl-multi-column

npm i https://pkg.pr.new/@blocknote/xl-multi-column@2978

@blocknote/xl-odt-exporter

npm i https://pkg.pr.new/@blocknote/xl-odt-exporter@2978

@blocknote/xl-pdf-exporter

npm i https://pkg.pr.new/@blocknote/xl-pdf-exporter@2978

commit: a43d8c0

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.

Slash menu throws "Attempting to update uninitialized suggestions menu" after toggling editable

1 participant