[TIMOB-28552] Android: ListView "move" event can return wrong "itemIndex" and is missing "target*" properties
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2021-10-20T03:12:44.000+0000 |
Affected Version/s | Release 9.3.0 |
Fix Version/s | Release 10.2.0 |
Components | Android |
Labels | ListView, android, editing, move, parity |
Reporter | Joshua Quick |
Assignee | Joshua Quick |
Created | 2021-10-12T18:20:25.000+0000 |
Updated | 2021-10-20T03:12:44.000+0000 |
Description
*Summary:*
Tap and hold the top most row. _(This is "itemIndex"
Notice the log states "itemIndex" is
ListView
"move" event has the following issues on Android...
* The "itemIndex" will return the wrong index if you drag-and-drop the ListItem
slowly. The index changes as the list items shift between the dragged item.
* The "targetSection", "targetSectionIndex", and "targetItemIndex" are undefined. This means we don't know where the ListItem
was moved to in the list.
*Steps to reproduce:*
Build and run the below on Android.
Tap and hold the top most row. _(This is "itemIndex" 0
.)_
Slowly drag it to the bottom of the section and release.
Notice the log states "itemIndex" is 2
when it should be 0
.
function createListViewSection(sectionTitle) {
const items = [];
for (let index = 1; index <= 4; index++) {
items.push({
properties: {
title: Row ${index}
,
canEdit: false,
canMove: true,
},
});
}
const section = Ti.UI.createListSection({
headerTitle: sectionTitle,
items: items,
});
return section;
}
const window = Ti.UI.createWindow();
const listView = Ti.UI.createListView({
sections: [
createListViewSection("Section 1"),
createListViewSection("Section 2"),
],
allowsSelectionDuringEditing: false,
allowsMultipleSelectionDuringEditing: false,
editing: true,
});
listView.addEventListener("move", (e) => {
const data = {
sectionIndex: e.sectionIndex,
itemIndex: e.itemIndex,
targetSectionIndex: e.targetSectionIndex,
targetItemIndex: e.targetItemIndex,
};
console.log(@@@ "move" event: ${JSON.stringify(data)}
);
});
window.add(listView);
window.open();
PR (master): https://github.com/appcelerator/titanium_mobile/pull/13120