Skip to content

fix(core): backspace mid-text next to columnList moves block BLO-1126#2629

Open
YousefED wants to merge 2 commits intomainfrom
fix/backspace-columnlist-mid-text
Open

fix(core): backspace mid-text next to columnList moves block BLO-1126#2629
YousefED wants to merge 2 commits intomainfrom
fix/backspace-columnlist-mid-text

Conversation

@YousefED
Copy link
Copy Markdown
Collaborator

@YousefED YousefED commented Apr 7, 2026

Summary

  • The "move to end of prev columnList" backspace handler was missing a selectionAtBlockStart guard, causing mid-text backspace next to a columnList to move the entire block into the column instead of deleting a character.
  • Added 3 unit tests for backspace behavior with multi-column blocks.

Closes #2621

Test plan

  • mid-text backspace next to columnList should not move block — verifies the fix
  • backspace at block start should move block into last column — verifies intended behavior
  • second backspace should merge into previous block in column — verifies merge after move
  • All existing xl-multi-column tests pass (56 passed, 5 skipped)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Fixed keyboard shortcut behavior in multi-column block layouts so actions only run when the cursor is exactly at the relevant block boundary, preventing unintended block moves.
  • Tests

    • Added thorough tests for Backspace/Delete in multi-column layouts, validating block movement into/out of columns and subsequent merging behavior via document snapshots.

…nList handler

The "move to end of prev columnList" backspace handler was missing a
check for whether the cursor is at the start of the block. This caused
mid-text backspace next to a columnList to move the entire block into
the column instead of deleting a character.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 7, 2026

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

Project Deployment Actions Updated (UTC)
blocknote Ready Ready Preview Apr 7, 2026 8:44am
blocknote-website Ready Ready Preview Apr 7, 2026 8:44am

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 7, 2026

📝 Walkthrough

Walkthrough

Adds selection-position guards to keyboard shortcuts that move blocks around multi-column (columnList) structures and adds Vitest coverage for Backspace/Delete behaviors around multi-column blocks. Changes prevent invalid relocations by verifying the cursor is at block start/end before mutating the document.

Changes

Cohort / File(s) Summary
Keyboard Shortcut Handler
packages/core/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts
Added explicit selection-position checks (e.g., selectionAtBlockStart) to columnList-related Backspace/Delete handlers and return early when the cursor is not at the required boundary before computing surrounding block info or applying moves.
Tests — multi-column keyboard behavior
packages/xl-multi-column/src/test/commands/backspace.test.ts
New Vitest suite exercising Backspace and Delete around columnList fixtures: mid-text (no move), boundary deletes (move block out/in), and repeated deletes (merge behavior). Uses editor snapshots for assertions.

Sequence Diagram(s)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • nperez0111
  • matthewlipski

Poem

🐰 Hopping keys and guarded bounds,
Cursor checks keep safe the rounds,
Columns steady, no more fright,
Backspace dances in the light. ✨

🚥 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
Description check ✅ Passed The description covers the key aspects: the bug fix, test plan with specific test cases, and references the resolved issue #2621.
Linked Issues check ✅ Passed The PR directly addresses issue #2621 by adding a selectionAtBlockStart guard to prevent RangeError when deleting after multi-column blocks, with corresponding test coverage.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the backspace/delete behavior with columnList blocks; no unrelated modifications were introduced.
Title check ✅ Passed The title accurately describes the main fix: adding a missing guard to prevent block movement when pressing Backspace mid-text next to a columnList, which directly addresses the changeset modifications to the KeyboardShortcutsExtension and the corresponding tests.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 fix/backspace-columnlist-mid-text

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 and usage tips.

… handler

Same bug as the backspace handler — the "move first block from next
columnList" delete handler was missing a selectionAtBlockEnd check,
causing mid-text delete next to a columnList to incorrectly move blocks.

Also adds 3 delete tests mirroring the backspace tests, and marks
the mid-text tests with TODOs for vitest browser mode migration.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 7, 2026

Open in StackBlitz

@blocknote/ariakit

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

@blocknote/code-block

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

@blocknote/core

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

@blocknote/mantine

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

@blocknote/react

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

@blocknote/server-util

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

@blocknote/shadcn

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

@blocknote/xl-ai

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

@blocknote/xl-docx-exporter

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

@blocknote/xl-email-exporter

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

@blocknote/xl-multi-column

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

@blocknote/xl-odt-exporter

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

@blocknote/xl-pdf-exporter

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

commit: 031c6fe

@YousefED YousefED changed the title fix(core): backspace mid-text next to columnList moves block fix(core): backspace mid-text next to columnList moves block BLO-1126 Apr 7, 2026
@YousefED
Copy link
Copy Markdown
Collaborator Author

YousefED commented Apr 7, 2026

fyi @nperez0111 @matthewlipski I think the keyboardshortcuts could use a rewrite in general. I'm not convinced the separation of different commands actually improve readability / testability.

Example: I think it would be a cleaner to have 1 if-statement that checks for "is cursor at block end", and within that determines the operation needed, versus what we have now: x different chained commands that all check independently whether "is cursor at block end"

@nperez0111
Copy link
Copy Markdown
Contributor

fyi @nperez0111 @matthewlipski I think the keyboardshortcuts could use a rewrite in general. I'm not convinced the separation of different commands actually improve readability / testability.

Yep, it's a mess. commands aren't the recommended pattern here

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.

RangeError: Position out of range when deleting after multi-column block

2 participants