-
6 Jul 2011 3:06 PM #1
Panels sometimes disappear when their siblings are collapsed
Panels sometimes disappear when their siblings are collapsed
Using Ext JS 4.0.2, I put two panels inside of a container, making both of them collapsible. When I collapse the first, then the second, the first panel disappears (visually at least). Here's the markup and code to reproduce it.
The same problem does not occur on Ext JS 3.3.1.Code:<link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-4.0.2/resources/css/ext-all.css"> <script type="text/javascript" src="http://extjs.cachefly.net/ext-4.0.2/ext-all-debug.js"></script> <script type="text/javascript"> Ext.onReady(function(){ new Ext.Container({ collapsible: true, items: [{ title: 'Collapse me first...', collapsible: true }, { title: '...and then me (first panel will disappear)', collapsible: true }], renderTo: Ext.getBody() }); }); </script>
Also, this only happens when the panels are in some kind of parent container. If the collapsible panels are appended directly to the document body, the problem does not occur.
Observations
- When a panel disappears, its top-level DOM element (<div id="panel-1015"...) has the style "width: 0;" applied directly to it.
- The header element (<div id="header-1018"...) has the same "width: 0;" style applied to it.
- Setting those widths back to the container width makes the panel reappear.
It looks like when we collapse a panel, it tells its parent container to "do layout", which in turn triggers the setting the width of its child panels. The problem occurs when one of those child panels was already collapsed. The reason is because of the how the child panel decides how wide it should be. It looks at the dimensions of its body. Since the body has the style "display: none;", its width is calculated as zero.
The bit of code I'm talking about is in the Ext.core.Element class:
When recalculating the child panel width, should we be basing it off the width of its own body, which in this case is 0 (because of the "display: none;")?Code:getWidth: function(contentWidth, preciseWidth) { var me = this, dom = me.dom, ... } else if (Ext.supports.BoundingClientRect) { // display is none, so this is a 0 x 0 box! rect = dom.getBoundingClientRect(); width = rect.right - rect.left; width = preciseWidth ? width : Math.ceil(width);
Here's the stack trace at this point:
Disclaimer: I may have totally misread it. This is the first time I'm digging into the Ext JS code.Code:Ext.override.getWidth() at ext-all-debug.js:8468 Ext.define.calculateDockBoxes() at ext-all-debug.js:24636 Ext.define.dockItems() at ext-all-debug.js:24572 Ext.define.onLayout() at ext-all-debug.js:24560 Ext.define.layout() at ext-all-debug.js:15598 Ext.define.doComponentLayout() at ext-all-debug.js:20259 Ext.define.setCalculatedSize() at ext-all-debug.js:20220 Ext.define.setItemSize() at ext-all-debug.js:22044 Ext.define.onLayout() at ext-all-debug.js:27973 Ext.define.layout() at ext-all-debug.js:15598 Ext.define.doContainerLayout() at ext-all-debug.js:16016 Ext.define.afterLayout() at ext-all-debug.js:16029 Ext.define.layout() at ext-all-debug.js:15602 Ext.define.doComponentLayout() at ext-all-debug.js:20259 Ext.define.doOwnerCtLayouts() at ext-all-debug.js:15995 Ext.define.layout() at ext-all-debug.js:15608 Ext.define.doComponentLayout() at ext-all-debug.js:20259 Ext.define.setSize() at ext-all-debug.js:20155 Ext.define.setAttr() at ext-all-debug.js:23825 Ext.define.applyPendingAttrs() at ext-all-debug.js:33943 Ext.define.runAnim() at ext-all-debug.js:33909 Ext.define.each() at ext-all-debug.js:17285 Ext.define.runner() at ext-all-debug.js:33857 runTasks() at ext-all-debug.js:5744
Last edited by Mike M. Lin; 6 Jul 2011 at 4:56 PM. Reason: Added observations from examining the DOM and code
-
6 Jul 2011 5:06 PM #2
Thanks for the report, I've pushed it into our issue tracker
-
17 Oct 2011 3:50 PM #3
Not working either
Not working either
Same issue here. Does later (commercial) releases of Ext JS have this issue.
Could someone confirm?
Could this issue be related to the layout? any thoughts
-
14 Nov 2011 6:06 PM #4
A work around
A work around
My company just got premium support with Sencha and while submitting a bug for this I ran into a solution.
Could someone explain what is going on here?Code:Ext.onReady(function () { Ext.create('Ext.container.Container', { defaults: { collapsible: true, width: 400 }, items: [{ title: 'Collapse me first...', html: 'Text 1' }, { title: '...and then me (first panel will disappear)', html: 'Text 2' }], renderTo: Ext.getBody() }); });
-
25 Jan 2012 12:46 AM #5
Hi,
I am having the same issue when using ext 4.0.7. Can someone provide a solution for this ?
Thank you,
Ana
-
14 Mar 2012 9:26 AM #6
I had this problem in another case with column layout and panels with height values.
The "solution" - if you can call it solution - was to simply add a width:100% to the child elements.
I dont know if this works in your case.
PHP Code:[...]
defaults: {
collapsible: true,
width: '100%'
},
[...]
-
6 Dec 2012 2:29 AM #7
this could fix the problem, however, while expanding and collapsing the panels with fixed height and 'autoScroll', sometimes the 'anchor' does not work well--very right part may hide under the scroll bar. But not big deal, compared with the original 'nothing' problem...
Success! Looks like we've fixed this one. According to our records the fix was applied for
EXTJSIV-3443
in
TBD.


Reply With Quote