Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-27118

Android: TabGroup close() wrongly fires "close" event twice

    Details

      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:

      1. Build and run the below code on Android.
      2. Tap on the "Show TabGroup" button.
      3. Tap on the "Close TabGroup" button.
      4. Notice in the log that a "TabGroup 'close'" was logged twice. (This is the bug.)
      5. Tap on the "Show TabGroup" button.
      6. Tap on the Android "Back" button to close the TabGroup.
      7. 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();
      

        Attachments

          Activity

            People

            • Assignee:
              ybanev Yordan Banev
              Reporter:
              jquick Joshua Quick
              Reviewer:
              Gary Mathews
              Tester:
              Keerthi Mahalingam (Inactive)
            • Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                  Git Source Code