Success! Looks like we've fixed this one. According to our records the fix was applied for EXTJS-6484 in a recent build.
  1. #1
    Sencha Premium Member
    Join Date
    Apr 2011
    Location
    Doylestown, PA
    Posts
    14
    Vote Rating
    0
    attila.huszko is on a distinguished road

      0  

    Default Ext.AbstractManager.onAvailable listener isn't removed properly

    Ext.AbstractManager.onAvailable listener isn't removed properly


    REQUIRED INFORMATION

    Ext version tested:
    • Ext 4.1

    Browser versions tested against:
    • Google Chrome 19

    DOCTYPE tested against:
    • <!DOCTYPE html>

    Description:
    • onAvailable function in class Ext.AbstractManager fails, because not the proper function will be removed after component being available.

    Steps to reproduce the problem:
    • Create onAvailable listener on component with id 'test'.
    • Create the component with id 'test'.
    • Function registered will fire once.
    • Destroy the component.
    • Add onAvailable listener on component with id 'test' again.
    • Create the component again with id 'test'.
    • Function will be fired twice...

    The result that was expected:
    • Callback should fire only one, once the component is available with the specified id.

    The result that occurs instead:
    • Function called as many times as onAvailable listener applied, even if the component was destroyed, then created again between each listener apply.

    Test Case:
    Code:
    Ext.ComponentManager.onAvailable('test', function() {
    alert('I am available, first!');
    });
    
    var component = Ext.create('Ext.Component', {
    id: 'test'
    });
    
    component.destroy();
    
    Ext.ComponentManager.onAvailable('test', function() {
    alert('I am available, second!');
    });
    
    Ext.create('Ext.Component', {
    id: 'test'
    });‚Äč
    

    HELPFUL INFORMATION

    Screenshot or Video:
    • none

    See this URL for live test case: http://jsfiddle.net/fNnzF/3/


    Debugging already done:
    • yes

    Possible fix:
    Code:
    onAvailable : function (id, callback, scope) {
        var all = this.all,
        item,
        fn;
        if (all.containsKey(id)) {
            item = all.get(id);
            callback.call(scope || item, item);
        } else {
            fn = function (map, key, item) {
                if (key == id) {
                    callback.call(scope || item, item);
                    all.un('add', fn);
                }
            };
            all.on('add', fn);
        }
    }
    Additional CSS used:
    • only default ext-all.css

    Operating System:
    • Windows 7

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,868
    Vote Rating
    438
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    Thank you for the report!

    Regards,
    Scott.

  3. #3
    Sencha User
    Join Date
    Apr 2007
    Posts
    160
    Vote Rating
    0
    vladsch is on a distinguished road

      0  

    Default


    This fix introduced new bug
    Try to add two 'onAvailable' listeners
    Code:
    Ext.ComponentManager.onAvailable('test1', function() {
         alert('I am available, first!');
    });
    
    Ext.ComponentManager.onAvailable('test2', function() {
         alert('I am available, second!');
    });
    
    var component = Ext.create('Ext.Component', {
    id: 'test1'
    });
    In this case, we will get an exception because event is removed during event firing