Skip to content

fix: Selecting multi-column slash menu items within a column (BLO-905) - #2914

Open
matthewlipski wants to merge 2 commits into
mainfrom
multi-column-slash-menu
Open

fix: Selecting multi-column slash menu items within a column (BLO-905)#2914
matthewlipski wants to merge 2 commits into
mainfrom
multi-column-slash-menu

Conversation

@matthewlipski

@matthewlipski matthewlipski commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR fixes an error thrown when selecting one of the multi-column slash menu items from within a column. Because having a columnList node inside a column violates the schema, this would throw an error. The fix is that when the item is selected, it checks if there is an ancestor column list from the text cursor position. If there is, a the item inserts the new column list after it, rather than after the current block.

Closes #1380

Rationale

This is a bug.

Changes

See above.

Impact

N/A

Testing

Added unit tests.

Screenshots/Video

N/A

Checklist

  • Code follows the project's coding standards.
  • Unit tests covering the new feature have been added.
  • All existing tests pass.
  • The documentation has been updated to reflect the new feature

Additional Notes

N/A

Summary by CodeRabbit

  • New Features

    • Enhanced the slash-menu options for inserting two- and three-column layouts.
    • Insertions now respect existing column context, adding a new top-level layout when appropriate.
    • After insertion, the cursor is moved into the newly created layout to streamline editing.
  • Bug Fixes

    • Improved fallback behavior when no column context is detected, ensuring the layout is still inserted reliably.
  • Tests

    • Added coverage for slash-menu items and the column insertion behavior in multiple cursor scenarios.

@matthewlipski
matthewlipski requested a review from YousefED July 23, 2026 17:10
@vercel

vercel Bot commented Jul 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
blocknote Ready Ready Preview Jul 24, 2026 3:31pm
blocknote-website Ready Ready Preview Jul 24, 2026 3:31pm

Request Review

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The slash menu now builds column lists through shared helpers, detects nested columnList ancestors, inserts after them when found, and positions the cursor in the inserted block. Tests cover top-level and nested insertion behavior.

Changes

Nested column insertion

Layer / File(s) Summary
Ancestor-aware column insertion
packages/xl-multi-column/src/extensions/SuggestionMenu/getMultiColumnSlashMenuItems.tsx, packages/xl-multi-column/src/extensions/SuggestionMenu/getMultiColumnSlashMenuItems.test.tsx
Adds reusable column-list construction and ancestor-aware insertion, wires two- and three-column slash-menu actions through it, and verifies document and cursor results in top-level and nested contexts.

Estimated code review effort: 3 (Moderate) | ~15 minutes

Suggested reviewers: yousefed

Poem

I’m a rabbit with columns to stack,
Nesting each neatly on track.
Two or three blooms,
In their proper rooms,
With the cursor hopping right back!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The code addresses #1380 by inserting a new column list outside an existing one and adds tests for the nested-column case.
Out of Scope Changes check ✅ Passed The changes stay focused on the reported multi-column insertion bug and the accompanying test coverage.
Title check ✅ Passed The title clearly describes the bug fix for multi-column slash menu selection within a column.
Description check ✅ Passed The description follows the template and covers summary, rationale, changes, impact, testing, and checklist items.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch multi-column-slash-menu

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.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/xl-multi-column/src/extensions/SuggestionMenu/getMultiColumnSlashMenuItems.tsx (1)

98-105: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

Add a regression test for nested insertion.

Cover both two- and three-column actions from inside a column, asserting that insertion succeeds, the new columnList is a sibling after the ancestor, the cursor lands in the inserted content, and the slash trigger is removed.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@packages/xl-multi-column/src/extensions/SuggestionMenu/getMultiColumnSlashMenuItems.tsx`
around lines 98 - 105, Add regression coverage for the two- and three-column
actions in getMultiColumnSlashMenuItems, invoking each from inside an existing
column. Assert insertion succeeds, the new columnList is inserted as a sibling
after the ancestor, the cursor is positioned in the inserted content, and the
slash trigger is removed.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@packages/xl-multi-column/src/extensions/SuggestionMenu/getMultiColumnSlashMenuItems.tsx`:
- Around line 73-81: Update the ancestorColumnList branch in
getMultiColumnSlashMenuItems so a slash-only trigger paragraph is cleared before
editor.insertBlocks runs. Mirror the cleanup behavior provided by
insertOrUpdateBlockForSlashMenu, while preserving the existing nested insertion
and cursor positioning flow.

---

Nitpick comments:
In
`@packages/xl-multi-column/src/extensions/SuggestionMenu/getMultiColumnSlashMenuItems.tsx`:
- Around line 98-105: Add regression coverage for the two- and three-column
actions in getMultiColumnSlashMenuItems, invoking each from inside an existing
column. Assert insertion succeeds, the new columnList is inserted as a sibling
after the ancestor, the cursor is positioned in the inserted content, and the
slash trigger is removed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5f3b86de-0ccb-4bc8-8af1-c64086ce9c07

📥 Commits

Reviewing files that changed from the base of the PR and between dee7880 and 766360b.

📒 Files selected for processing (1)
  • packages/xl-multi-column/src/extensions/SuggestionMenu/getMultiColumnSlashMenuItems.tsx

Comment on lines +73 to +81
if (ancestorColumnList) {
const newBlock = editor.insertBlocks(
[columnList],
ancestorColumnList,
"after",
)[0];
editor.setTextCursorPosition(newBlock, "start");
} else {
insertOrUpdateBlockForSlashMenu(editor, columnList);

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Clear the slash-trigger block before inserting outside the ancestor.

When the menu is opened from an empty paragraph containing only /, this branch bypasses insertOrUpdateBlockForSlashMenu, which normally replaces that block. insertBlocks leaves the original paragraph unchanged, so nested insertion can leave a visible / in the existing column. Mirror the core helper’s slash-only cleanup before inserting the new list.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@packages/xl-multi-column/src/extensions/SuggestionMenu/getMultiColumnSlashMenuItems.tsx`
around lines 73 - 81, Update the ancestorColumnList branch in
getMultiColumnSlashMenuItems so a slash-only trigger paragraph is cleared before
editor.insertBlocks runs. Mirror the cleanup behavior provided by
insertOrUpdateBlockForSlashMenu, while preserving the existing nested insertion
and cursor positioning flow.

@pkg-pr-new

pkg-pr-new Bot commented Jul 23, 2026

Copy link
Copy Markdown

Open in StackBlitz

@blocknote/ariakit

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

@blocknote/code-block

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

@blocknote/core

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

@blocknote/mantine

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

@blocknote/react

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

@blocknote/server-util

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

@blocknote/shadcn

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

@blocknote/xl-ai

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

@blocknote/xl-docx-exporter

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

@blocknote/xl-email-exporter

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

@blocknote/xl-multi-column

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

@blocknote/xl-odt-exporter

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

@blocknote/xl-pdf-exporter

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

commit: 516a9a9

@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://TypeCellOS.github.io/BlockNote/pr-preview/pr-2914/

Built to branch gh-pages at 2026-07-24 15:34 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@YousefED

Copy link
Copy Markdown
Collaborator

Great, can you add a test?

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.

Error encountered when inserting multiple columns into multiple columns

2 participants