Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2278] ListView itemclick event itemIndex inconsistent between Android and iOS

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionDuplicate
Resolution Date2014-01-12T19:17:21.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsn/a
ReporterRudolf Cardinal
AssigneeRitu Agrawal
Created2014-01-12T16:52:23.000+0000
Updated2016-03-08T07:41:17.000+0000

Description

Steps to Reproduce

Run this code:
var items = ['one', 'two', 'three', 'four', 'five'];
var data = [];
for (var i = 0; i < items.length; ++i) {
    data.push( { properties: {
        itemId: i,
        title: items[i],
        searchableText: items[i],
    } } );
}
var section = Titanium.UI.createListSection();
section.setItems(data);
var listView = Titanium.UI.createListView({
    canScroll: true,
    caseInsensitiveSearch: true,
    searchView: Titanium.UI.createSearchBar({
        top: 0,
        left: 0,
        height: 45,
        showCancel: false,
    }),
    sections: [section],
});
listView.addEventListener('itemclick', function (e) {
    Titanium.API.trace('itemclick from listView: e.itemIndex = ' + JSON.stringify(e.itemIndex) + ', e.sectionIndex = ' + JSON.stringify(e.sectionIndex) + ', e.itemId = ' + JSON.stringify(e.itemId) );
});
var win = Ti.UI.createWindow({ backgroundColor: '#fff' });
win.add(listView);
win.open();

// ANDROID 4.1.1/Titanium 3.2.0: When a listview is filtered, itemId remains unchanged, but itemIndex is the index of the filtered content (e.g. always 0 if you've filtered down to one thing).
// iOS 7.0.3/Titanium 3.2.0: When a listview is filtered, itemIndex continues to reference the unfiltered list.

Actual Result

ANDROID 4.1.1/Titanium 3.2.0: When a listview is filtered, itemId remains unchanged, but itemIndex is the index of the filtered content (e.g. always 0 if you've filtered down to one thing). iOS 7.0.3/Titanium 3.2.0: When a listview is filtered, itemIndex continues to reference the unfiltered list.

Expected Result

Same result on both platforms. (The obvious workaround is to use itemId, which is consistent.)

Attachments

FileDateSize
.log2014-01-12T16:52:35.000+00005822040
diagnostic1541366633337341993.log2014-01-12T16:52:42.000+000015690

Comments

  1. Ritu Agrawal 2014-01-12

    Resolving this ticket as a duplicate of TIMOB-16079. Please track that ticket for further updates.

JSON Source