Skip to content

fix(track-changes): allow backspace on empty list items in suggesting mode (SD-2187)#2472

Open
tupizz wants to merge 1 commit intomainfrom
fix/empty-list-item-backspace-suggesting-mode
Open

fix(track-changes): allow backspace on empty list items in suggesting mode (SD-2187)#2472
tupizz wants to merge 1 commit intomainfrom
fix/empty-list-item-backspace-suggesting-mode

Conversation

@tupizz
Copy link
Contributor

@tupizz tupizz commented Mar 19, 2026

Demo

CleanShot.2026-03-19.at.15.20.55.mp4

Summary

  • Fixes inability to delete an empty list bullet in suggesting mode after all text has been tracked-deleted
  • Root cause: replaceAroundStep handler blocked structural changes (e.g. lift out of list) when findPreviousLiveCharPos returned null, leaving the user stuck on an undeletable empty bullet
  • Fix: when no live characters remain, allow the structural ReplaceAroundStep to apply directly instead of blocking it

Root Cause

The replaceAroundStep handler (introduced in PR #2225 / SD-2061) converts backspace ReplaceAroundStep operations into tracked single-character deletions. When all text in a list item is already marked as trackDelete, findPreviousLiveCharPos() returns null and the handler returned early, blocking the structural change entirely.

The fix allows the structural step to pass through when the content is effectively empty. Structural changes aren't tracked yet (as noted in the ticket), but blocking them is worse than applying them untracked.

Test plan

  • All 847 super-editor test files pass (9214 tests, 0 failures)
  • Updated test case to verify structural step is attempted (not blocked) when no live characters exist
  • Verified in browser: delete all text in numbered list item in suggesting mode, then backspace removes the bullet
  • Manual: upload TC bulleted test.docx, switch to suggesting mode, delete list item text, backspace to remove bullet
  • Manual: verify same fix works for indented list items

… mode (SD-2187)

When all text in a list item was deleted in suggesting mode (marked as
trackDelete), pressing backspace to remove the bullet did nothing. The
replaceAroundStep handler blocked the structural change because
findPreviousLiveCharPos returned null (no un-deleted text left).

Allow the structural ReplaceAroundStep (e.g. lift out of list) to apply
when there are no live characters remaining. Structural changes aren't
tracked yet, but blocking them leaves the user stuck on an empty bullet
they can't remove.
@linear
Copy link

linear bot commented Mar 19, 2026

@tupizz tupizz self-assigned this Mar 19, 2026
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4cc21ad078

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines 112 to +118
if (deleteFrom === null) {
// No live character found — nothing to delete. Skip the structural change.
// No live character to delete — the list item / block is effectively empty
// (all content already tracked-deleted). Allow the structural change
// (e.g. lifting out of list) to apply directly. Structural changes aren't
// tracked yet, but blocking them leaves the user stuck on an empty bullet
// they can't remove (SD-2187).
if (!newTr.maybeStep(step).failed) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep structural backspace blocked on non-empty items

This branch now treats deleteFrom === null as “effectively empty”, but findPreviousLiveCharPos() only looks at text before the caret. When the caret is at the start of a non-empty list item in suggesting mode, deleteFrom is also null, so pressing Backspace will apply the original ReplaceAroundStep untracked and lift/outdent the item, dropping list/paragraph properties instead of preserving them as tracked text changes. The direct structural step needs an additional check that the whole block/list item is already fully deleted, not just that there is no live character before the cursor.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant