Description
When calling updateSection for a tableviewsection with the index number that once referenced a deleted section, it appears that the deleted section is updated and readded to the tableview.
The code below does the following:
Create a tableview with two sections
When the window opens, delete the section at index 1 and append a new section
When a tableviewrow is clicked, update the section at index
On Android and iOS this code works as expected, with the title of the 2 section being updated
var win = Ti.UI.createWindow();
var sectionFruit = Ti.UI.createTableViewSection({
headerTitle: 'Fruit'
});
sectionFruit.add(Ti.UI.createTableViewRow({ title: 'Apples' }));
sectionFruit.add(Ti.UI.createTableViewRow({ title: 'Bananas' }));
var testSection = Ti.UI.createTableViewSection({
headerTitle: 'Test'
});
var table = Ti.UI.createTableView({
data: [sectionFruit, testSection]
});
win.addEventListener('open', function() {
table.deleteSection(1);
table.appendSection(createSection('newSection'));
var sections = table.sections;
for(var i = 0; i < sections.length; i++) {
console.log(sections[i].headerTitle);
}
});
table.addEventListener('click', function() {
table.updateSection(1, createSection('updateSection'));
var sections2 = table.sections;
console.log(table.sections.length);
for(var i = 0; i < sections2.length; i++){
console.log(sections2[i].headerTitle);
}
});
function createSection(title){
return section = Ti.UI.createTableViewSection({ headerTitle: title});
}
win.add(table);
win.open();
Steps to reproduce
1. Using the code above, build for Windows Platform using
appc run -p windows -T wp-emulator
2. Tap one of the rows in the first section
Actual result
There are now 3 sections Fruit, updateSection and newSection
Expected result
There should only be 2 sections Fruit and updateSection
Verified using: OS: Microsoft Windows 10 Pro 10.0.14393 Appc core: 6.0.0-38 Appc NPM: 4.2.8-6 Ti SDK: 6.0.0.v20160904203840 Lumia 930: 10.0 Demo code in the description now works as expected Closing ticket