diff --git a/.changeset/chatty-monkeys-hear.md b/.changeset/chatty-monkeys-hear.md new file mode 100644 index 000000000..8f8d01daf --- /dev/null +++ b/.changeset/chatty-monkeys-hear.md @@ -0,0 +1,5 @@ +--- +"@tiptap/extension-list-keymap": patch +--- + +Fix backspace behavior when selection is not collapsed diff --git a/packages/extension-list-keymap/src/listHelpers/handleBackspace.ts b/packages/extension-list-keymap/src/listHelpers/handleBackspace.ts index e1fc012ce..506347f31 100644 --- a/packages/extension-list-keymap/src/listHelpers/handleBackspace.ts +++ b/packages/extension-list-keymap/src/listHelpers/handleBackspace.ts @@ -12,6 +12,12 @@ export const handleBackspace = (editor: Editor, name: string, parentListTypes: s return true } + // if the selection is not collapsed + // we can rely on the default backspace behavior + if (editor.state.selection.from !== editor.state.selection.to) { + return false + } + // if the current item is NOT inside a list item & // the previous item is a list (orderedList or bulletList) // move the cursor into the list and delete the current item