Skip to content

Commit fa8d41c

Browse files
authored
fix(core): backspace mid-text next to columnList moves block BLO-1126 (#2629)
* fix(core): add missing selectionAtBlockStart guard in backspace columnList 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. * fix(core): add missing selectionAtBlockEnd guard in delete columnList 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.
1 parent 5d980c4 commit fa8d41c

File tree

3 files changed

+914
-2
lines changed

3 files changed

+914
-2
lines changed

packages/core/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,13 @@ export const KeyboardShortcutsExtension = Extension.create<{
136136
return false;
137137
}
138138

139+
const selectionAtBlockStart =
140+
state.selection.from ===
141+
blockInfo.blockContent.beforePos + 1;
142+
if (!selectionAtBlockStart) {
143+
return false;
144+
}
145+
139146
const prevBlockInfo = getPrevBlockInfo(
140147
state.doc,
141148
blockInfo.bnBlock.beforePos,
@@ -462,15 +469,22 @@ export const KeyboardShortcutsExtension = Extension.create<{
462469

463470
return false;
464471
}),
465-
// If the previous block is a columnList, moves the current block to
466-
// the end of the last column in it.
472+
// If the next block is a columnList, moves the first block from its
473+
// first column to after the current block.
467474
() =>
468475
commands.command(({ state, tr, dispatch }) => {
469476
const blockInfo = getBlockInfoFromSelection(state);
470477
if (!blockInfo.isBlockContainer) {
471478
return false;
472479
}
473480

481+
const selectionAtBlockEnd =
482+
state.selection.from ===
483+
blockInfo.blockContent.afterPos - 1;
484+
if (!selectionAtBlockEnd) {
485+
return false;
486+
}
487+
474488
const nextBlockInfo = getNextBlockInfo(
475489
state.doc,
476490
blockInfo.bnBlock.beforePos,

0 commit comments

Comments
 (0)