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

iOS: TabGroup focus event firing unexpectedly

    Details

    • Type: Bug
    • Status: Closed
    • Priority: None
    • Resolution: Fixed
    • Affects Version/s: Release 9.1.0
    • Fix Version/s: Release 9.3.0
    • Component/s: iOS
    • Labels:
    • Story Points:
      5
    • Sprint:
      2020 Sprint 19, 2020 Sprint 20, 2020 Sprint 21, 2020 Sprint 22

      Description

      Description

      When listening to a TabGroup's focus event it is firing unexpectedly, for example it will fire in the following scenarios:

      • When opening a new Window with the TabGroup
      • After closing an alert

      I'm guessing this is coming the changes in TIMOB-27711 so it's possible that this might be an expected change in behaviour.

      To workaround this and restore the behaviour of 9.0.3 the previousTab property of the event can be checked, if it is null then it was fired by an action matching those in 9.0.3.

      var basewin = Ti.UI.createWindow({
      	backgroundColor : 'white',
      	layout : 'vertical'
      });
       
      var baseWinBtn = Ti.UI.createButton({
      	title : 'open Nav Root win with delay',
      	top : 60
      });
       
      function getNavRootWin(title) {
      	var win = Ti.UI.createWindow({
      		backgroundColor : 'white',
      		title : title
      	});
      	var navWin = Titanium.UI.createNavigationWindow({
      		window : win
      	})
      	return navWin;
      }
       
      baseWinBtn.addEventListener('click', function() {
      	var indWin = Ti.UI.createWindow({
      		backgroundColor : 'red'
      	});
      	indWin.open();
      	setTimeout(function() {
      		indWin.close();
      		var navRootWn = getNavRootWin('Dynamic window');
      		tab.open(navRootWn);
      	}, 500);
      });
      basewin.add(baseWinBtn);
      var baseWinBtn1 = Ti.UI.createButton({
      	title : 'open Nav Root win without delay',
      	top : 60
      });
      baseWinBtn1.addEventListener('click', function() {
      	var indWin = Ti.UI.createWindow({
      		backgroundColor : 'red'
      	});
      	indWin.open();
      	indWin.close();
      	var navRootWn = getNavRootWin('static window');
      	var openWin = Ti.UI.createButton({
      		title : "open dynamic win"
      	});
      	openWin.addEventListener('click',function(){
      	indWin.open();
      	setTimeout(function(){
      		indWin.close();
      	navRootWn.openWindow(Ti.UI.createWindow({
      		backgroundColor : 'white'
      	}));
      	},500);
      	})
      	
      	navRootWn.add(openWin);
      	tab.open(navRootWn);
      });
      basewin.add(baseWinBtn1);
      var baseWinBtn2 = Ti.UI.createButton({
      	title : 'open Nav Root win to check alertdialog',
      	top : 60
      });
      baseWinBtn2.addEventListener('click', function() {
      	var navwin = getNavRootWin('Alert window');
      	var alertBtn = Ti.UI.createButton({
      		title :'click to get alert'
      	});
      	alertBtn.addEventListener('click',function(){
      		Ti.UI.createAlertDialog({
      			title : "test",
      			message : "test msg",
      			buttonNames : ['OK']
      		}).show();
      	});
      	navwin.add(alertBtn);
      	tab.open(navwin);
      });
      basewin.add(baseWinBtn2);
      var tabGroup = Ti.UI.createTabGroup({
      	title : '',
      	titleColor : "#bbb",
      	tintColor : "#bbb",
      	navBarHidden : true
      });
      var tab = Ti.UI.createTab({
      	title : 'tab1',
      	window : basewin
      });
      tabGroup.addTab(tab);
      var tab2 = Ti.UI.createTab({
      	title : 'tab2',
      	window : Ti.UI.createWindow({backgroundColor : 'white'})
      });
      tabGroup.addTab(tab2);
      tabGroup.open();
      tabGroup.addEventListener('focus',function(e){
          // if (!e.previousTab) {
          //     return;
          // }
      	Ti.API.info('in tabgroup focus');
      });
      

      Steps to reproduce

      1. Add the above code to an existing app.js and build to iOS
      2. Click on “open Nav Root win with delay” and check the logs (tabgroup focus event fired)
      3. Click on “open Nav Root win without delay” and check the logs (tabgroup focus event not fired)
      4. Click on “open Nav Root win to check alertdialog” and click on “click to get alert” button and click “OK” button of alert dialog and check the logs (tabgroup focus event fired)

      Actual

      focus event fires in steps 2,3, and 4.

      Expected

      (9.0.3 behaviour)

      Focus event should only fire when selected the second tab

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                vijaysingh Vijay Singh
                Reporter:
                eharris Ewan Harris
                Reviewer:
                Christopher Williams
                Tester:
                Samir Mohammed
              • Watchers:
                6 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 Integration