Skip to content

fix(caret): treat line breaks as visible content - #3084

Open
Anurag-S1ngh wants to merge 1 commit into
codex-team:nextfrom
Anurag-S1ngh:fix/2296-leading-line-break
Open

Anurag-S1ngh wants to merge 1 commit into
codex-team:nextfrom
Anurag-S1ngh:fix/2296-leading-line-break

Conversation

@Anurag-S1ngh

Copy link
Copy Markdown
Contributor

Summary

checkContenteditableSliceForEmptiness only inspected textContent. A <br> has no text content, so a block starting with a line break was treated as empty before the caret. The Backspace handler then assumed the caret was at the start of the block and did not let the browser delete the line break.

Line breaks are now treated as visible content when checking both sides of the caret.

Changes

  • Return false from the emptiness check when the examined slice contains a <br>.
  • Add a Cypress test that presses Backspace at the start of a block with a leading <br> and expects it to be removed.

Testing

  • yarn lint
  • yarn test:e2e (390 passing)

Closes #2296

@Anurag-S1ngh
Anurag-S1ngh requested a review from neSpecc as a code owner December 3, 2026 11:55

This branch has not been deployed

No deployments
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.

Bug: Deletion of leading new lines in block not possible

1 participant