Skip to content

Read on-trailing-press on list items - #108

Draft
simonhamp wants to merge 1 commit into
mainfrom
fix/list-item-trailing-press
Draft

simonhamp wants to merge 1 commit into
mainfrom
fix/list-item-trailing-press

Conversation

@simonhamp

Copy link
Copy Markdown
Member

Setting on-trailing-press on a <native:list-item> did nothing. The trash button showed up, but tapping it never reached the component. This came up in several benchmark runs building a todo app, and people ended up rebuilding rows by hand.

The native side was fine. Both renderers already send on_trailing_press when the trailing icon button is tapped. The problem was in ListItem::applyAttributes(), which read on-leading-change and on-trailing-change but never read a trailing press attribute. So the callback could only be set with the fluent onTrailingPress(). It now accepts on-trailing-press and onTrailingPress, the same spellings as the change callbacks. I also added a line and an example to the Boost guideline.

One thing to watch: the accessibility docs page shows @trailing-press="...". That form still won't work, and a plugin can't fix it. Core's precompiler turns unknown @name= attributes into _event-name child-component bindings, and the collector strips those from plain elements before applyAttributes runs. The docs should use on-trailing-press instead.

Testing:

  • New tests/ListItemTrailingPressTest.php covers both spellings, a tag compiled through the real precompiler with a bound argument, the no-callback case and the fluent builder. Five of those fail on main. The full suite passes against nativephp/mobile 4.5.2.
  • On an iPhone 17 simulator I built a super-native screen with keyed todo rows using on-trailing-press="deleteTodo({{ $todo['id'] }})". Tapping a row's trash button removed the row and updated a "Deleted: 2" label. The @trailing-press version of the same row did nothing, which is how I found the core issue above.
  • No Swift or Kotlin changes, so no Android device run.

🤖 Generated with Claude Code

ListItem::applyAttributes never read a trailing press attribute, so the
handler could only be set with the fluent onTrailingPress() builder.
Both renderers already fire on_trailing_press from the trailing icon
button, so accepting on-trailing-press / onTrailingPress (the same
spellings as on-trailing-change) is the whole fix.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.

1 participant