Repository navigation
Conversation
…ols with line breaks In a Tool with enableLineBreaks, browsers wrap each line created by Enter in a <div>. Dom.findAllInputs() lists those divs as separate inputs, so Backspace at the start of a line was treated as "caret at the start of a non-first input" and moved the caret to the previous line instead of removing the line break. Delete had the same problem at the end of a line. Leave the native behaviour when there is other content before (or after) the line in the same contenteditable. The first line and the last line keep the existing Block behaviour.
b84330808
requested review from
TatianaFomina,
gohabereg,
ilyamore88 and
neSpecc
as code owners
November 11, 2026 08:17
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2854. The same bug is reported in #2730, #2685 and #2609.
In a Tool with
enableLineBreaks(Quote, or a custom contenteditable Tool), each Enter makes the browser wrap the new line in a<div>, andDom.findAllInputs()lists every one of those divs as a separate input. So Backspace at the start of any line after the first is caught byBlockEvents.backspace(), which callsCaret.navigatePrevious(): the caret jumps up a line and the line break stays. Delete does the same at the end of a line (navigateNext()). Repro on the editorjs.io demo: add a Quote, type something, press Enter a few times, then Backspace.backspace()anddelete()now leave the key to the browser when the caret's input is a line inside a contenteditable that has visible content (text, a<br>or another line) before it, for Backspace, or after it, for Delete. At the start of the first line and the end of the last line the Block behaviour is unchanged, and separate inputs like the Quote text and caption are not affected.New cases in
Backspace.cy.tsandDelete.cy.tsuse a Tool withenableLineBreaks. The four that remove an empty line or join two lines fail onnextand pass with this change; the two that check the first/last line Block behaviour pass on both. The full Cypress suite passes in Chrome.