feat: moveBlocks behaviour when leaving empty columns (BLO-1109)#2842
feat: moveBlocks behaviour when leaving empty columns (BLO-1109)#2842matthewlipski wants to merge 3 commits into
moveBlocks behaviour when leaving empty columns (BLO-1109)#2842Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThis PR changes block moving to run removal and insertion inside a transaction while skipping intermediate column cleanup during removal. It also updates tests to cover moving blocks past empty siblings in multi-column content. ChangesBlock Move Column-Fixing Refactor
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
|
Moves are rearrangements rather than deletions, so columns that a move empties out are deliberately left as-is instead of being collapsed. This keeps moves free of side effects (and reversible by moving back), matches dragging a block out of a column, and fixes the original error: collapsing a transiently-empty column mid-move broke the re-insertion. Also simplifies `removeAndInsertBlocks` (plain `fixColumns` opt-out, no `affectedColumnLists` return) and removes the columnList reference anchoring workaround in `moveBlocks`, which guarded against mid-move collapsing that can no longer happen. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
@matthewlipski I pushed 2f1af8f on top of your fix — could you review? It changes the approach based on a policy decision: Moves no longer collapse emptied columns at all. Instead of deferring Follow-on simplifications:
Since this is now a behavior change rather than just an error fix, the PR title/description should probably be updated to say so (e.g. "moveBlocks no longer collapses emptied columns") — that's worth surfacing in the changelog. 🤖 Generated with Claude Code |
@blocknote/ariakit
@blocknote/code-block
@blocknote/core
@blocknote/mantine
@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: |
I think it's a good change, don't see issues with it. The one caveat I have is that drag & drop is also a rearrangement rather than a deletion, yet drag & drop does remove empty columns. I think for logical consistency, maybe these should have the same behaviour. But I'd rather do that in a separate PR if anything. |
moveBlocks in columns (BLO-1109)moveBlocks behaviour when leaving empty columns (BLO-1109)
moveBlocks behaviour when leaving empty columns (BLO-1109)moveBlocks behaviour when leaving empty columns (BLO-1109)
Good point. @virgile-dev do you have an opinion on this? (It would make dragging the last block out of a column not remove that column as it is now (but keep an empty block around) |
Summary
This PR fixes an edge case when using
moveBlockswith columns.moveBlocksfirst removes the target block(s), then inserts it/them above/below the previous/next block. In the removal step,fixColumnsis called for all affected column lists, collapsing them or individual columns when they're empty.This causes an error in the following case:
When moving the non-empty paragraph block up, it's first removed. This leaves the column with a single empty paragraph, which
fixColumnsreads as an empty column, and so collapses it. Upon re-insertion, the reference block no longer exists and an error is thrown. This also happens when the order of the 2 blocks is flipped and the non-empty one is moved down.After reviewing this, we have decided to change the behaviour of
moveBlocksto not callfixColumns. If a column is left empty after a move, it's filled with an empty paragraph.Closes #2594
Rationale
This is a bug, but also made us realize that we want to change the behaviour of
moveBlocksto not remove empty columns altogether.Changes
See above.
Impact
N/A
Testing
Added unit tests.
Screenshots/Video
N/A
Checklist
Additional Notes
N/A
Summary by CodeRabbit
Bug Fixes
Tests