Results 1 to 7 of 7

Thread: Disabled button enables when parent container got enabled

    Success! Looks like we've fixed this one. According to our records the fix was applied for EXTJS-17103 in 5.1.2.
  1. #1
    Sencha Premium Member
    Join Date
    Nov 2010
    Posts
    53

    Default Disabled button enables when parent container got enabled

    Ext version tested:
    • 5.1.1.347
    Description:
    • Container with button both set 'disabled: true' explicitly. When parent container is set enabled button also looks enabled.
    Steps to reproduce the problem:
    The result that was expected:
    • Button to remain visually disabled
    The result that occurs instead:
    • Button visually enabled
    I know there are similar threads:
    http://www.sencha.com/forum/showthread.php?295910 (says fixed)
    http://www.sencha.com/forum/showthread.php?296873 (dup)

    But there were opposite problem: button with initial enabled state remained disabled when parent container was set enabled.

    Problem code:

    Ext.container.Container:
    Code:
        /**     
         * @override
         * Disables all child input fields and buttons.
         */
        disable: function(silent, /* private */fromParent) {
            var me = this,
                wasDisabled = me.disabled,
                itemsToDisable, len, i;
    
    
            me.callParent([silent, fromParent]);
    
    
            if (!fromParent && !me.preventChildDisable && !wasDisabled) {
                itemsToDisable = me.getChildItemsToDisable();
                len = itemsToDisable.length;
    
    
                for (i = 0; i < len; i++) {
                    itemsToDisable[i].disable(silent, true); // button doesn't respect second argument
                }
            }
            return me;
        },
    
    
        /**
         * @override
         * Enables all child input fields and buttons.
         */
        enable: function(silent, /* private */fromParent) {
            var me = this,
                wasDisabled = me.disabled,
                itemsToDisable, len, i;
    
    
            me.callParent([silent, fromParent]);
    
    
            if (wasDisabled) {
                itemsToDisable = me.getChildItemsToDisable();
                len = itemsToDisable.length;
    
    
                for (i = 0; i < len; i++) {
                    itemsToDisable[i].enable(silent, true); // button doesn't respect second argument
                }
            }
    
    
            return me;
        },
    Last edited by Alexey.Solonets; 18 Mar 2015 at 6:08 AM. Reason: title changed

  2. #2
    Sencha Premium Member
    Join Date
    Nov 2010
    Posts
    53

    Default

    Workaround (may be not perfect)
    Code:
    Ext.define('Ext.bf.button.Button', {
        override: 'Ext.button.Button',
        
        enable: function (silent, fromParent) {
            fromParent = !!fromParent;
            if (fromParent == this.disabledFromParent) {
                this.callParent(arguments);
            }
            else if (fromParent) {
                this.disabledFromParent = false;
            }
        },
    
    
        disable: function (silent, fromParent) {
            fromParent = !!fromParent;
            if (!this.disabled) {
                this.disabledFromParent = fromParent;
                this.callParent(arguments);
            }
        }
    });

  3. #3
    Sencha User
    Join Date
    Feb 2013
    Location
    California
    Posts
    11,985

    Default

    Thanks for the report and workaround! I have opened a bug in our bug tracker.

  4. #4
    Sencha Premium Member
    Join Date
    Nov 2010
    Posts
    53

    Default

    Another workaround that is better for me so far

    Code:
    Ext.define('Ext.bf.button.Button', {
        override: 'Ext.button.Button',
        
        enable: function (silent, fromParent) {
            if (!fromParent) {
                this.callParent(arguments);
            }
        },
    
    
        disable: function (silent, fromParent) {
            if (!fromParent) {
                this.callParent(arguments);
            }
        }
    });

  5. #5
    Sencha Premium User
    Join Date
    Feb 2011
    Location
    Cambridge, MA
    Posts
    1,295

    Default

    Opened Sencha ticket 22400 to get this resolved in a timely fashion.

  6. #6
    Sencha Premium User
    Join Date
    Feb 2011
    Location
    Cambridge, MA
    Posts
    1,295

    Default

    That issue have not been looked at by Sencha since 2015-03-27. Why the override is just not integrated to the framework?

  7. #7
    Ext JS Premium Member
    Join Date
    Dec 2011
    Posts
    234

    Default

    I've got the same problem.
    My version is 5.1.1.451.
    Any solution from Sencha support???

Posting Permissions

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