Description
*The original Android ticket that this test came from was related to searchbar but this occurs when the searchbar isn't added too, when testing please ensure both (with searchbar and without searchbar) are exercised*
When adding a tableview back to a windows after removing it the app will freeze and crash
var _window = Ti.UI.createWindow();
var flag = false;
var data = [{
title: 'Row 1',
hasChild: true,
color: 'red',
header: 'First'
}, {
title: 'Row 2',
hasDetail: true,
color: 'green'
}, {
title: 'Row 3',
hasCheck: true,
color: 'blue',
header: 'Second'
}, {
title: 'Row 4',
color: 'orange'
}];
var sb = Titanium.UI.createSearchBar({
barColor: '#122a6f',
showCancel: false,
height: 44,
});
// Create a TableView.
var table = Ti.UI.createTableView({
height: 600,
width: '100%',
search: sb,
top: 75,
left: 0,
data: data
});
_window.add(table);
var button = Ti.UI.createButton({
title: 'Show / Hide',
height: 75,
width: '100%',
top: 0,
left: 0
});
_window.add(button);
button.addEventListener('click', function() {
if (true == flag) {
_window.add(table);
flag = false;
} else {
_window.remove(table);
flag = true;
}
});
_window.open()
Steps to reproduce
Add the above code to an existing app.js
Tap the button at the top
Tap the button again
Actual
TableView is removed on first click, app freezes and crashes on second click
Expected
TableView is removed on first click, readded on second click
https://github.com/appcelerator/titanium_mobile_windows/pull/1129
Tested on SDK 7.0.0.v20171116132144 installed from CLI. Fix is verified.