[TIMOB-28291] View events in a ListView ItemTemplate doesn't include property type
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | None |
Status | Closed |
Resolution | Unresolved |
Affected Version/s | Release 9.3.0 |
Fix Version/s | Release 9.3.1 |
Components | Android |
Labels | listview, regression |
Reporter | Rodrigo Farfán |
Assignee | Gary Mathews |
Created | 2020-12-15T12:22:43.000+0000 |
Updated | 2021-01-19T19:53:52.000+0000 |
Description
I've got a ListView with an ItemTemplate on which some Views have onSingletap and onDoubletap listeners
My alloy View:
<Alloy>
<Collection id="avisosCorporativos" src="AvisoCorporativo" instance="true"/>
<Window id="win" onOpen="win_onOpen" onClose="win_onClose" backgroundColor="#fff">
<ListView id="lvAvisos" defaultItemTemplate="template" height="Ti.UI.SIZE">
<Templates>
<ItemTemplate name="template" class="defaultTemplate">
<View class="vTemplateContainer" onLongpress="gestureForwarder">
<View class="vMessageRow1" bindId="vMessageRow1">
<Label id="lMessageReadStatus" bindId="lMessageReadStatus"/>
<Label id="lMessageSubject" bindId="lMessageSubject" onSingletap="gestureForwarder" onDoubletap="gestureForwarder"/>
</View>
<View class="vMessageRow2" bindId="vMessageRow2">
<Label id="lMessageDate" bindId="lMessageDate"/>
<Label id="lMessagePriority" bindId="lMessagePriority"/>
</View>
</View>
</ItemTemplate>
</Templates>
<ListSection id="listSection" dataCollection="$.avisosCorporativos" dataTransform="_listSection_dataTransform">
<ListItem lMessageReadStatus:text="{ReadStatus}"
lMessageSubject:text="{Asunto}"
lMessageSubject:font="{Font}"
lMessageDate:text="{Fecha}"
lMessagePriority:text="{Priority}"
/>
</ListSection>
</ListView>
</Window>
</Alloy>
In controller, gestureForwarder handler function simply logs the event payload "stringified" and attribute .type is undefined. I've fixed this rebuilding the SDK with a little modification. In ListItemProxy.java, in function generateViewFromTemplate, adding this line
payload.put(TiC.EVENT_PROPERTY_TYPE, eventName);
Besides this, I observe another 2 issues:
1) If I add onClick event for a view in the template that also has the onSingletap o onDoubletap, both events are triggered (click+singletap or click+doubletap).
2) The onLongpress event is also triggered without the .type property and, in this case, all the listview properties (sectionIndex, itemIndex, etc...) are not included either. (Same with swipe events)
All this events are working fine on SDK 9.2 and lower.
I can repro this issue, classic code that repros the missing type property. However I'm seeing that click+singletap are fired on 9.2.2.GA also so might not be identical to the Alloy code
Hmmmm... maybe I'm confused about the click+singletap on 9.2 (must check it again). Regarding classic code and longpress event, did you notice what I said about the list related properties (sectionIndex, itemIndex,...)?
As we've also discussed on TiSlack, I would like to point out events bound on specific UI elements in ListViews might not behave as you can expect, and any "working" behaviour in the past is not something you should be trusting. If you need to bind eventListeners on UI elements it is recommended to use TableViews. Excerpt from the ListView documentation:
List view is designed for performance. One side effect of the design is that you cannot directly manipulate the views--add children, set view properties and bind event callbacks--as you can in TableView. Instead, you interact with list items indirectly, using templates and data items.
The ListView does however appear to have issues with not all event properties propagating properly it seems (like bindId)master: https://github.com/appcelerator/titanium_mobile/pull/12348
FR Passed, waiting on Jenkins build.
merged to master, backport for 9_3_X merged for 9.3.1 target.