Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27118] Android: TabGroup close() wrongly fires "close" event twice

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2019-09-10T05:06:07.000+0000
Affected Version/sn/a
Fix Version/sRelease 8.3.0
ComponentsAndroid
LabelsTabGroup, android, close, engSchedule, event
ReporterJoshua Quick
AssigneeYordan Banev
Created2019-06-01T02:53:55.000+0000
Updated2019-09-10T05:06:07.000+0000

Description

*Summary:* When calling a 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();

Comments

  1. Yordan Banev 2019-07-19

    PR (master):https://github.com/appcelerator/titanium_mobile/pull/11062
  2. Keerthi Mahalingam 2019-07-31

    FR passed. Tab group close event fired only once. works as expected.PR will be merged after 8.1.0 GA
  3. Yordan Banev 2019-08-26

    PR (8_3_X): https://github.com/appcelerator/titanium_mobile/pull/11175
  4. Christopher Williams 2019-09-09

    merged master PR. Closed 8_3_X PR as that branch will be going away and master is current 8.3.0 target.
  5. Keerthi Mahalingam 2019-09-10

    Verified the fix on sdk 8.3.0.v20190909144256. Tabgroup works as expected.
       Test Environment:
        Name                        = Mac OS X
         Version                     = 10.14.5
         Architecture                = 64bit
         # CPUs                      = 12
         Memory                      = 17179869184
       Node.js
         Node.js Version             = 10.16.2
         npm Version                 = 6.9.0
       Titanium CLI
         CLI Version                 = 5.2.1
       Titanium SDK
         SDK Version                 = 8.3.0.v20190909144256
       Device -samsung s5 android 6
       Emulator- pixel android 9
       

JSON Source