Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-28554] Android: TableView "move" event returns wrong "row" and "index"

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2021-10-20T03:13:05.000+0000
Affected Version/sRelease 9.3.0
Fix Version/sRelease 10.2.0
ComponentsAndroid
LabelsTableView, android, editing, move, parity
ReporterJoshua Quick
AssigneeJoshua Quick
Created2021-10-14T00:59:16.000+0000
Updated2021-10-20T03:13:05.000+0000

Description

*Summary:* TableView "move" event properties "row" and "index" return the wrong values when dragging it. These properties should return the row that's being dragged, but instead returns the last row that was dragged over. *Steps to reproduce:*

Build and run the below on Android.

Tap and hold the top most row. (Named "Row 1".)

Drag and drop it all the way to the bottom of the TableView in Section 2.

Observe the log and notice it returns the wrong row name and index.

function createTableViewSection(sectionTitle) {
	const section = Ti.UI.createTableViewSection({ headerTitle: sectionTitle });
	section.add(Ti.UI.createTableViewRow({ title: "Row 1", editable: false, moveable: true }));
	section.add(Ti.UI.createTableViewRow({ title: "Row 2", editable: false, moveable: true }));
	section.add(Ti.UI.createTableViewRow({ title: "Row 3", editable: false, moveable: true }));
	section.add(Ti.UI.createTableViewRow({ title: "Row 4", editable: false, moveable: true }));
	return section;
}

const window = Ti.UI.createWindow();
const tableView = Ti.UI.createTableView({
	data: [
		createTableViewSection("Section 1"),
		createTableViewSection("Section 2"),
	],
	allowsSelectionDuringEditing: false,
	allowsMultipleSelectionDuringEditing: false,
	editing: true,
});
tableView.addEventListener("move", (e) => {
	const data = {
		sectionTitle: e.section.headerTitle,
		rowTitle: e.row.title,
		index: e.index,
	};
	console.log(@@@ "move" event: ${JSON.stringify(data)});
});
window.add(tableView);
window.open();
*Result:* The above "Steps to reproduce" logs the following. This is wrong since you dragged "Row 1", not "Row 4". Also, "index" should be 7 which is the last position in the TableView, not 6 which is the 2nd to last position. The issue is the event always contains info if the last row dragged over.
 @@@ "move" event: {"sectionTitle":"Section 2","rowTitle":"Row 4","index":6}

Comments

  1. Joshua Quick 2021-10-14

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/13120

JSON Source