Results 1 to 3 of 3

Thread: [6.x.x] TabPanel event activate not fired for first added tab

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha Premium User vadimv's Avatar
    Join Date
    Sep 2010
    Location
    Cluj, Romania
    Posts
    811

    Default [6.x.x] TabPanel event activate not fired for first added tab

    Happens from 6.5.2 to 6.6.0. Can find a test case in the following thread: https://www.sencha.com/forum/showthr...irst-added-tab
    Github https://github.com/vadimpopa
    Blogging @ : http://vadimpopa.com
    Twitter: @vadimvpopa

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,450

    Default

    This looks like the onAdd method of Ext.tab.Panel only setting a default active item if the tab panel has a loader defined. There is this code and pay attention to the comment:

    Code:
            // Ensure that there is at least one active tab. This is only needed when adding tabs via a loader config, i.e., there 
            // may be no pre-existing tabs. Note that we need to check if activeTab was explicitly set to `null` in the tabpanel 
            // config (which tells the layout not to set an active item), as this is a valid value to mean 'do not set an active tab'. 
            if (me.rendered && me.loader && me.activeTab === undefined && me.layout.activeItem !== null) {
                me.setActiveTab(0);
            }
    I don't agree that it's only needed when adding tabs via a loader config. I think if you add an item to a tab panel without an active item then it's reasonable to make that new item active. Therefor you can create an override to patch this:

    Code:
    Ext.define(null, {
        override: 'Ext.tab.Panel',
        
        onAdd: function (item, index) {
            const me = this
            
            me.callParent([ item, index ])
            
            if (me.rendered && me.activeTab === undefined && me.layout.activeItem !== null) {
                me.setActiveTab(0);
            }
        }
    })
    Here's a fiddle:

    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

  3. #3
    Sencha Premium User vadimv's Avatar
    Join Date
    Sep 2010
    Location
    Cluj, Romania
    Posts
    811

    Default

    Hey man,

    thanks for taking a look, I haven't had time to find an override for it, being pressed by the sprint deadline, was easier for me to finish the ticket with a temp quick dirty fix and then later look on it when having a free window (since I like puzzling too on issues with overrides )
    Code:
                tabPanel.setActiveTab(analyseTab);
    
    
                // ExtJS doesn't fire activate when first item is added, so have to do it here
                if (tabPanel.items.getCount() === 1) {
                    analyseTab.fireEvent('activate');
                }
    Yeah, I agree too with your conclusion on that comment. So I think we miss the last piece to your solution: removing that tab and adding back should fire activate event as well. To me makes sense that we have to override the doRemove and replace the null with undefined on activeTab assignment, when removing the tab, and callSuper.

    Code:
    doRemove: function
    
      if (me.removingAll || me.destroying || me.items.getCount() === 1) {
                    me.activeTab = undefined; // Replace null with undefined
                }
    Github https://github.com/vadimpopa
    Blogging @ : http://vadimpopa.com
    Twitter: @vadimvpopa

Similar Threads

  1. activate event not getting fired on my custom ExtJS button
    By krishnakumar1981 in forum Ext: Discussion
    Replies: 3
    Last Post: 12 Nov 2013, 2:57 AM
  2. Activate not being fired on panel within tabpanel
    By iamcootis in forum Ext: Discussion
    Replies: 1
    Last Post: 24 May 2013, 9:06 AM
  3. Replies: 1
    Last Post: 28 Dec 2012, 9:02 AM
  4. TabPanel 'added' not fired when I call 'add'
    By bimargulies in forum Ext: Q&A
    Replies: 1
    Last Post: 25 Jul 2012, 7:27 AM
  5. TabPanel auto activate added tabs
    By maxserv-remco in forum Ext 3.x: Help & Discussion
    Replies: 10
    Last Post: 1 Dec 2009, 10:33 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •