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

Android: Window/TabGroup close() method call is ignored until "open" event has been fired

    Details

    • Story Points:
      5
    • Sprint:
      2019 Sprint 9, 2019 Sprint 10

      Description

      Summary:
      On Android, a Ti.UI.Window or Ti.UI.TabGroup object's close() method call is ignored if it hasn't finished opening yet. The Window or TabGroup will remain open and not automatically close itself.

      This means the following won't close the window. The window will remain open.

      var window = Ti.UI.createWindow();
      window.open();
      window.close();  // <- This method call will be ignored.
      

      Steps to reproduce:

      1. Build and run the below code on Android.
      2. Tap on the "Open/Close Window" button.
      3. Notice a red window is displayed. (This is a bug. The close() method was ignored.)
      4. Press the Android "Back" button.
      5. Tap on the "Open/Close TabGroup" button.
      6. Notice a red tab group is displayed. (This is a bug. The close() method was ignored.)

      var parentWindow = Ti.UI.createWindow();
      var openWindowButton = Ti.UI.createButton({
      	title: "Open/Close Window",
      	top: "30%",
      });
      openWindowButton.addEventListener("click", function() {
      	var childWindow = Ti.UI.createWindow({ backgroundColor: "red" });
      	childWindow.add(Ti.UI.createLabel({
      		text: "Uh-oh!",
      		color: "white",
      	}));
      	childWindow.open();
      	childWindow.close();  // <- This method call will be ignored.
      });
      parentWindow.add(openWindowButton);
      var openTabGroupButton = Ti.UI.createButton({
      	title: "Open/Close TabGroup",
      	top: "50%"
      });
      openTabGroupButton.addEventListener("click", function() {
      	function createTab(title) {
      		var window = Ti.UI.createWindow({ title: title, backgroundColor: "red" });
      		window.add(Ti.UI.createLabel({ text: "Uh-oh!", color: "white" }));
      		var tab = Ti.UI.createTab({
      			title: title,
      			window: window,
      		});
      		return tab;
      	}
      	var tabGroup = Ti.UI.createTabGroup({
      		tabs: [createTab("Tab 1"), createTab("Tab 2"), createTab("Tab 3")],
      	});
      	tabGroup.open();
      	tabGroup.close();  // <- This method call will be ignored or crash in older versions.
      });
      parentWindow.add(openTabGroupButton);
      parentWindow.open();
      

      Note:
      For TabGroup, calling the close() method will crash if the app was built with Titanium 7.x.x or older versions. In Titanium 8.0.0, it does not crash and the method call is ignored.

      Expected Result:
      The close() method call should be respected, eve before the window has finished opening. This is how it works on iOS. The only time close() should be ignored is if the window has never been opened or has already been closed.

      Work-around:
      Don't call the close() method until the "open" event has been fired.

        Attachments

          Activity

            People

            • Assignee:
              jquick Joshua Quick
              Reporter:
              jquick Joshua Quick
              Reviewer:
              Gary Mathews
              Tester:
              Lokesh Choudhary
            • Watchers:
              3 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