Results 1 to 3 of 3

Thread: Ext.container.AbstractContainer#suspendLayout is not reentrant

    Success! Looks like we've fixed this one. According to our records the fix was applied for EXTJS-4192 in a recent build.
  1. #1
    Ext JS Premium Member
    Join Date
    Jul 2011

    Default Ext.container.AbstractContainer#suspendLayout is not reentrant


    Ext version tested:
    Ext 4.0.2a

    Browser versions tested against:
    FF3 (firebug installed)

    The configuration field suspendLayout in AbstractContainer is not reentrant when combining add/removes. The methods removeAll and add([]) override the field in their implementation and do not restore the original value. This results in callers having to reimplement removeAll/addAll in order to remove all elements and adding other elements and delaying layout until the end of the complete operation.

    Steps to reproduce the problem:
    • Have a container c
    • Set suspendLayout to true: c.suspendLayout = true
    • Remove all elements: c.removeAll()
    • Add new elements els: c.add(els)
    • Notice that suspendLayout has been set to false and a layout operation has been performed after removing all elements.

    The result that was expected:
    • No layout operation performed until after explicitly doing so after removing/adding all operations
    • suspendLayout should still be true after removing and adding element arrays.

    The result that occurs instead:
    • Layout was performed both after removing all items and adding new ones.
    • suspendLayout was set to true.

    Test Case:

    See above.


    Screenshot or Video:
    Not applicable.

    See this URL for live test case: http://
    Not applicable.

    Debugging already done:
    • yes

    Possible fix:
    • a. Document that removeAll, add overrides suspendLayout
    • b. Layout only if suspendLayout is not initially true. Restore value.

    Possible fix for b - example with removeAll:
        removeAll : function(autoDestroy) {
            var me = this,
                removeItems = me.items.items.slice(),
                items = [],
                i = 0,
                len = removeItems.length,
            // Suspend Layouts while we remove multiple items from the container
    +++     // Restore suspended layout configuration
    +++     var layoutWasSuspended = me.suspendLayout;
            me.suspendLayout = true;
            for (; i < len; i++) {
                item = removeItems[i];
                me.remove(item, autoDestroy);
                if (item.ownerCt !== me) {
    ~~~     // Resume Layouts now that all items have been removed and do a single layout
    +++     // Resume layout only if it has not been suspended or if there has been items removed 
    ~~~     if (len && !layoutWasSuspended) {
    +++         me.suspendLayout = false;
    +++     me.suspendLayout = layoutWasSuspended;
            return items;
    Additional CSS used:
    Not applicable.

    Operating System:
    Windows 7

  2. #2
    Sencha Premium User SebTardif's Avatar
    Join Date
    Feb 2011
    Cambridge, MA


    I have the same problem. Is it possible to get a bug id assigned to this?

  3. #3
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Sydney, Australia


    This will be resolved in 4.1 as part of some of the layout refactoring that's going on.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

Posting Permissions

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