fix(core): don't throw when the suggestion menu opens while not editable - #2978
fix(core): don't throw when the suggestion menu opens while not editable#2978adarshsm wants to merge 1 commit into
Conversation
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.
|
@adarshsm is attempting to deploy a commit to the TypeCell Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan includes up to 10 reviews per rolling hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe 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. ChangesSuggestion menu fix
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to 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: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
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
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. Comment |
@blocknote/ariakit
@blocknote/code-block
@blocknote/core
@blocknote/diagram-block
@blocknote/mantine
@blocknote/math-block
@blocknote/react
@blocknote/server-util
@blocknote/shadcn
@blocknote/xl-ai
@blocknote/xl-docx-exporter
@blocknote/xl-email-exporter
@blocknote/xl-multi-column
@blocknote/xl-odt-exporter
@blocknote/xl-pdf-exporter
commit: |
Closes #2701
Problem
Toggling the editor to non-editable right as the suggestion (slash) menu opens — which a controlled
editableprop can do under load — leavesSuggestionMenuViewwithout astate, because the menu never gets shown. The stop / non-editable branch ofupdate()then calledemitUpdateunconditionally, which throws: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 callingemitUpdate.Test
does not throw when the menu opens while not editable (#2701)setseditor.isEditable = falseand then opens the suggestion menu, reproducing the crash deterministically. It throws onmainand passes with this change.Summary by CodeRabbit
Bug Fixes
Tests