Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-18099] iOS: Parity: Clean up tab events

GitHub Issuen/a
TypeImprovement
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2015-10-22T02:01:23.000+0000
Affected Version/sRelease 3.5.0
Fix Version/sRelease 5.1.0
ComponentsiOS
LabelsTCSupport
ReporterMark Mokryn
AssigneeAngel Petkov
Created2014-11-06T16:06:13.000+0000
Updated2016-02-15T13:50:48.000+0000

Description

1. In Android we have the click event on the tab, but in iOS we do not. This event should be removed for Android as well, since it's confusing and quite useless as tabs can be selected by swipes. 2. In Android since 3.5.0 we have the tab selected and unselected events. In iOS we have focus/blur which fire exactly when the tab is selected and unselected. So iOS tab focus/blur should be renamed selected/unselected to match Android. 3. Tab focus/blur should be removed since we have selected/unselected which are much clearer, and since it makes no sense for tabs to be focused/blurred. Focus/blur events should occur on the Window or perhaps on the entire tab group, but not for "tabs" which are only used for selection and are not really a containing UI element. Note that for Android tab focus/blur fire in numerous cases, not just tab selection, and in all "relevant" cases we have Window focus/blur in any case so for tabs they're redundant.

Comments

  1. Fokke Zandbergen 2015-09-03

    [~cng] In SDK 4.1.0 and 5.0.0 at least, the focus and blur events for iOS don't even include the index, previousIndex, tab and previousTab properties that the docs say it has, so they are useless. We should indeed bring the selected and unselected events to iOS.
  2. Angel Petkov 2015-09-17

    *PR* https://github.com/appcelerator/titanium_mobile/pull/7239#issuecomment-143895561 DemoCode:
       var win1 = Ti.UI.createWindow({
           backgroundColor: 'blue',
           title: 'Blue'
       });
       win1.add(Ti.UI.createLabel({text: 'I am a blue window.'}));
       
       var win2 = Ti.UI.createWindow({
           backgroundColor: 'red',
           title: 'Red'
       });
       win2.add(Ti.UI.createLabel({text: 'I am a red window.'}));
       
       var tab1 = Ti.UI.createTab({
           window: win1,
           title: 'Blue'
       }),
       tab2 = Ti.UI.createTab({
           window: win2,
           title: 'Red'
       }),
       tabGroup = Ti.UI.createTabGroup({
           tabs: [tab1, tab2]
       });
       
           //Should display deprecated message.
       tabGroup.addEventListener("focus", function(e){
        Ti.API.info("Index "+ e.index);
        });
        tabGroup.addEventListener("blur", function(e){
         Ti.API.info("Index "+ e.index);
       });
          //New Events
         tabGroup.addEventListener("selected", function(e){
          Ti.API.info("Index "+ e.index);
        });
          tabGroup.addEventListener("unselected", function(e){
           Ti.API.info("Index "+ e.index);
        });
       tabGroup.open();
       
  3. Chee Kiat Ng 2015-09-29

    Thanks [~apetkov], PR reviewed and merged!
  4. Harry Bryant 2015-10-13

    Verified as fixed, using the demo code provided by [~apetkov] I am able to see the deprecated messages for focus / blur when selecting tabs. Confirmed as working for iOS9 simulator & device. OSX El Capitan 10.11 Studio: 4.3.1.201509302304 Ti SDK: 5.2.0.v20151009071418 Appc NPM: 4.2.1-1 Appc CLI: 5.1.0-38
  5. Eric Wieber 2015-10-29

    Verified fixed, using: MacOS 10.11.2 (15C27e) Studio 4.4.0.201510280736 Ti SDK 5.1.0.v20151028190028 Appc NPM 4.2.1 Appc CLI 5.1.0-38 Ti CLI 5.0.5 Alloy 1.7.16 Arrow 1.3.13 Xcode 7.2 (7C46l) Node v0.12.7 Java 1.7.0_80 production Deprecation messages appear for blur/focus events and parity will be achieved with the linked, related ticket
  6. Fokke Zandbergen 2015-11-10

    This implementation we now have doesn't make much sense... When the TabGroup opens unselected and then selected are both fired. Only the last one could make sense, although I'd say the initial state should not fire events:
       [INFO]  Ti.UI.TabGroup:unselected {
       [INFO]    "index": 0,
       [INFO]    "tab": "[Ti.UI.Tab] #permissions",
       [INFO]    "previousIndex": 0,
       [INFO]    "bubbles": true,
       [INFO]    "type": "unselected",
       [INFO]    "source": "[Ti.UI.TabGroup] #index",
       [INFO]    "cancelBubble": false
       [INFO]  }
       [INFO]  Ti.UI.TabGroup:selected {
       [INFO]    "previousIndex": -1,
       [INFO]    "previousTab": null,
       [INFO]    "tab": "[Ti.UI.Tab] #permissions",
       [INFO]    "index": 0,
       [INFO]    "bubbles": true,
       [INFO]    "type": "selected",
       [INFO]    "source": "[Ti.UI.TabGroup] #index",
       [INFO]    "cancelBubble": false
       [INFO]  }
       
    I guess best is to resolve TIMOB-19759 and then deprecate>remove these.

JSON Source