[TIMOB-19253] iOS: Clicking a list item while editing the list does not fire itemclick event
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | Medium |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2016-05-13T20:52:30.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | Release 5.4.0 |
| Components | iOS |
| Labels | qe-5.4.0 |
| Reporter | Be Rushton |
| Assignee | Angel Petkov |
| Created | 2015-07-24T05:34:13.000+0000 |
| Updated | 2016-06-22T17:11:29.000+0000 |
Description
Test code:
var win = Ti.UI.createWindow({backgroundColor: 'white'});
var listViewEditing = false;
var listView = Ti.UI.createListView({editing: listViewEditing, height: 100, top: 20});
var sections = [];
var fruitSection = Ti.UI.createListSection({ headerTitle: 'Fruits'});
var fruitDataSet = [
{properties: { title: 'Apple', canEdit: true}},
{properties: { title: 'Banana'}},
];
fruitSection.setItems(fruitDataSet);
sections.push(fruitSection);
listView.sections = sections;
listView.addEventListener('itemclick', function() {
alert("itemclick");
// BUG: this only fires when listView.editing is false
});
win.add(listView);
var button = Ti.UI.createButton({title: "Toggle editing"});
button.addEventListener('click', function() {
listViewEditing = !listViewEditing;
listView.editing = listViewEditing;
});
win.add(button);
win.open();
Anyone going to look at this?
[~morahman] did you check this out on tableview? [~apetkov] can do some research here. But from what I know, I think for iOS in edit mode, natively, it's not possible to fire an item click event, but instead it enters a mode where you can select files. If so, the docs may need some additional instructions.
Hello [~cng], I have tested in tableview. I see this is also happening for tableview. Tableview click event does not fired with "editing : true" in tableview.
Regards, Sharif.Ti.UI.backgroundColor = 'white'; var win = Ti.UI.createWindow(); var tableData = [{ title : 'Apples' }, { title : 'Bananas' }, { title : 'Carrots' }, { title : 'Potatoes' }]; var table = Ti.UI.createTableView({ data : tableData, editing : true }); win.add(table); table.addEventListener('click', function() { alert("itemclick"); // BUG: this only fires when TableView.editing is false }); win.open();On iOS theres a property called "AllowsSelectionDuringEditing" which is by default set to false. Introducing the property fixes the issues. PR: https://github.com/appcelerator/titanium_mobile/pull/7995/files
Ti.UI.backgroundColor = 'white'; var win = Ti.UI.createWindow(); var listView = Ti.UI.createListView({ headerTitle : "ListView", height : "50%", top : 0, editing : true, allowsSelectionDuringEditing : true, }); var sections = []; var fruitSection = Ti.UI.createListSection({ headerTitle: 'Fruits'}); var fruitDataSet = [ {properties: { title: 'Apple', canEdit: true}}, {properties: { title: 'Banana', canEdit: true}}, {properties: { title: 'Apple', canEdit: true}}, {properties: { title: 'Banana', canEdit: true}}, {properties: { title: 'Apple', canEdit: true}}, {properties: { title: 'Banana', canEdit: true}} ]; fruitSection.setItems(fruitDataSet); sections.push(fruitSection); listView.sections = sections; listView.addEventListener('itemclick', function() { alert("itemclick"); // BUG: this only fires when listView.editing is false }); var tableData = [{ title : 'Apples' }, { title : 'Bananas' }, { title : 'Carrots' }, { title : 'Potatoes' }]; var table = Ti.UI.createTableView({ headerTitle : "TableView", data : tableData, height : "50%", bottom : "0", editing : true, allowsSelectionDuringEditing : true }); table.addEventListener('click', function() { alert("itemclick"); }); win.add(listView); win.add(table); win.open();There already is this property for the Ti.UI.TableView: http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.TableView-property-allowsSelectionDuringEditing So two things: - Remove the tableview-implementation from your PR, its a duplicate - Make sure the default behavior matches the iOS behavior - Provide default values in the setters [~bearus] Can you verify that PR works for you?
Ah yeah i didn't see my bad, thanks. Updated the PR : * Removed the table view implementation * Renamed the list view implementation to mach the table view property. * Added default setters.
Verified as fixed, ListView and TableViews can fire itemclick events during editing when
allowsSelectionDuringEditingis set to true. The default when this property is not set isfalse. Tested On: iPhone 6S (9.3.2) Device Mac OSX El Capitan 10.11.5 Ti SDK: 5.4.0.v20160617074028 Appc Studio: 4.7.0.201606150733 Appc NPM: 4.2.7-2 App CLI: 5.4.0-18 Xcode 7.3 Node v4.2.6 *Closing ticket.*