[TIMOB-27118] Android: TabGroup close() wrongly fires "close" event twice
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2019-09-10T05:06:07.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 8.3.0 |
Components | Android |
Labels | TabGroup, android, close, engSchedule, event |
Reporter | Joshua Quick |
Assignee | Yordan Banev |
Created | 2019-06-01T02:53:55.000+0000 |
Updated | 2019-09-10T05:06:07.000+0000 |
Description
*Summary:*
When calling a Notice in the log that a
Tap on the Android "Back" button to close the
Notice in the log that
TabGroup
object's close()
method, that TabGroup
will fire a "close" event twice when it shouldn't.
If you tap the Android "Back" button, then it will correctly fire the "close" event only once. This is only an issue when calling the close()
method.
*Steps to reproduce:*
Build and run the below code on Android.
Tap on the "Show TabGroup" button.
Tap on the "Close TabGroup" button.
Notice in the log that a "TabGroup 'close'"
was logged twice. _(This is the bug.)_
Tap on the "Show TabGroup" button.
Tap on the Android "Back" button to close the TabGroup
.
Notice in the log that "TabGroup 'close'"
was only logged once. _(This is correct.)_
var TAB_GROUP_REQUESTING_CLOSE_EVENT_NAME = "tabGroup:requestingClose";
function createTab(title) {
var window = Ti.UI.createWindow({ title: title });
window.add(Ti.UI.createLabel({ text: title + " View" }));
var closeButton = Ti.UI.createButton({
title: "Close TabGroup",
bottom: "20%",
});
closeButton.addEventListener("click", function() {
Ti.App.fireEvent(TAB_GROUP_REQUESTING_CLOSE_EVENT_NAME);
});
window.add(closeButton);
var tab = Ti.UI.createTab({
title: title,
window: window,
});
return tab;
}
var parentWindow = Ti.UI.createWindow();
var showTabGroupButton = Ti.UI.createButton({ title: "Show TabGroup" });
showTabGroupButton.addEventListener("click", function() {
function onRequestingClose() {
tabGroup.close();
}
var tabGroup = Ti.UI.createTabGroup({
tabs: [createTab("Tab 1"), createTab("Tab 2"), createTab("Tab 3")],
});
if (Ti.App.iOS) {
tabGroup.backgroundColor = "white";
}
tabGroup.addEventListener("open", function(e) {
Ti.App.addEventListener(TAB_GROUP_REQUESTING_CLOSE_EVENT_NAME, onRequestingClose);
Ti.API.info("@@@ TabGroup 'open' event was fired.");
});
tabGroup.addEventListener("close", function(e) {
Ti.App.removeEventListener(TAB_GROUP_REQUESTING_CLOSE_EVENT_NAME, onRequestingClose);
Ti.API.info("@@@ TabGroup 'close' event was fired.");
});
tabGroup.open();
});
parentWindow.add(showTabGroupButton);
parentWindow.open();
PR (master):https://github.com/appcelerator/titanium_mobile/pull/11062
FR passed. Tab group close event fired only once. works as expected.PR will be merged after 8.1.0 GA
PR (8_3_X): https://github.com/appcelerator/titanium_mobile/pull/11175
merged master PR. Closed 8_3_X PR as that branch will be going away and master is current 8.3.0 target.
Verified the fix on sdk 8.3.0.v20190909144256. Tabgroup works as expected.