Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-28552

Android: ListView "move" event can return wrong "itemIndex" and is missing "target*" properties

    Details

      Description

      Summary:
      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:

      1. Build and run the below on Android.
      2. Tap and hold the top most row. (This is "itemIndex" 0.)
      3. Slowly drag it to the bottom of the section and release.
      4. 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();
      

        Attachments

          Activity

            People

            • Assignee:
              jquick Joshua Quick
              Reporter:
              jquick Joshua Quick
              Reviewer:
              Gary Mathews
            • Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                  Git Integration