Skip to content

Keep an emptied list item on Android until a second backspace - #960

Merged
hanzei merged 1 commit into
masterfrom
claude/list-item-deletion-behavior-zqtg1q
Sep 6, 2026
Merged

Keep an emptied list item on Android until a second backspace#960
hanzei merged 1 commit into
masterfrom
claude/list-item-deletion-behavior-zqtg1q

Conversation

@hanzei

@hanzei hanzei commented Sep 6, 2026

Copy link
Copy Markdown
Owner

What & why

On Android, deleting the last character of a list item deleted the whole
item in a single backspace. The desired behaviour: clearing the last character
should leave the item present but empty, and only a second backspace should
remove the row.

Root cause

Android's TextInput delivers onKeyPress after the edit has been applied,
so on the keystroke that clears a row's last character the handler already sees
text === ''. The empty-backspace handler (ListItem.tsx) could not tell that
apart from a backspace on an already-empty row, so it removed the row on the
same press. iOS delivers onKeyPress before the edit, which is why it was
never affected (and the webapp, which uses the browser's keydown, already
does the two-step correctly).

Fix

mobile/src/components/ListItem.tsx now arms the delete on the first empty
keystroke and only removes the row on the next backspace:

  • A new emptyBackspaceArmedRef starts armed when the row mounts empty (a
    freshly added item), so backspacing that still removes it on the first press.
  • onChangeText disarms it on every edit; the Backspace handler re-arms it once
    the row is empty.
  • iOS/other platforms keep the simpler pre-edit text === '' check, so their
    behaviour is unchanged (two presses to remove a row that had text).

Net effect on every platform: clearing the last character leaves an empty row,
and a second backspace removes it (the row's other items are untouched and focus
moves to the previous row, as before).

Testing

  • task check-mobile — lint + all 1437 mobile tests pass, translations in sync.
  • New regression tests in mobile/__tests__/ListItem.test.tsx cover the
    Android last-character / second-backspace sequence, the already-empty
    first-press delete, and the iOS ordering.

Notes

  • Mobile-only change; no API or schema impact, nothing to migrate.
  • No visual artifact — the change is a keyboard-interaction fix with no UI
    appearance change.
  • A separate, deferred follow-up: aligning the webapp's whitespace-only handling
    (text.trim() === '') with mobile's exact-empty check.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HohdygPggGGcC5ypT7ze4X


Generated by Claude Code

On Android, TextInput delivers onKeyPress *after* the edit is applied, so
the keystroke that clears a row's last character already reports an empty
`text`. The empty-backspace handler could not tell that apart from a
backspace on an already-empty row, so clearing the last character deleted
the whole row in a single press.

Arm the delete on the first empty keystroke and only remove the row on the
next backspace, so clearing the last character leaves an empty row instead.
A row that mounts empty (e.g. a freshly added item) starts armed, so
backspacing it still removes it on the first press. iOS delivers onKeyPress
before the edit, so it keeps the simpler pre-edit `text === ''` check.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HohdygPggGGcC5ypT7ze4X
@coderabbitai

coderabbitai Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: f0dcb968-c297-48df-99b7-f995c54256f9

📥 Commits

Reviewing files that changed from the base of the PR and between 3ffc4c4 and 2e23c4b.

📒 Files selected for processing (2)
  • mobile/__tests__/ListItem.test.tsx
  • mobile/src/components/ListItem.tsx

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


Walkthrough

ListItem now handles backspace events differently on Android and iOS. Android tracks the backspace that clears the final character and removes the row only on the next backspace. iOS retains the existing empty-text check. Tests cover controlled rows, initially empty rows, platform-specific key-event ordering, and platform restoration.

Poem

I tap the keys with paws so light
A row stays still when text takes flight
The next soft press may send it away
Android waits; iOS knows the way
Tests hop and cheer in tidy array

Merge Risk: ⚪ Minimal · up to 2e23c

Android now retains a list item after its final character is removed and deletes it on the next backspace, while iOS behavior remains unchanged. No current merge-readiness risk is identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main Android behavior change: an emptied list item remains until a second backspace.
Description check ✅ Passed The description directly explains the Android backspace issue, root cause, implementation, tests, and expected behavior.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@hanzei
hanzei marked this pull request as ready for review September 6, 2026 10:59
@hanzei
hanzei merged commit 51d85ea into master Sep 6, 2026
9 checks passed
@hanzei
hanzei deleted the claude/list-item-deletion-behavior-zqtg1q branch September 6, 2026 13:10
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.

2 participants