Keep an emptied list item on Android until a second backspace - #960
Conversation
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
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. Walkthrough
Poem
Merge Risk: ⚪ Minimal · up to 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)
✅ Passed checks (4 passed)
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. Comment |
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
TextInputdeliversonKeyPressafter 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 thatapart from a backspace on an already-empty row, so it removed the row on the
same press. iOS delivers
onKeyPressbefore the edit, which is why it wasnever affected (and the webapp, which uses the browser's
keydown, alreadydoes the two-step correctly).
Fix
mobile/src/components/ListItem.tsxnow arms the delete on the first emptykeystroke and only removes the row on the next backspace:
emptyBackspaceArmedRefstarts armed when the row mounts empty (afreshly added item), so backspacing that still removes it on the first press.
onChangeTextdisarms it on every edit; the Backspace handler re-arms it oncethe row is empty.
text === ''check, so theirbehaviour 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.mobile/__tests__/ListItem.test.tsxcover theAndroid last-character / second-backspace sequence, the already-empty
first-press delete, and the iOS ordering.
Notes
appearance change.
(
text.trim() === '') with mobile's exact-empty check.🤖 Generated with Claude Code
https://claude.ai/code/session_01HohdygPggGGcC5ypT7ze4X
Generated by Claude Code