PDA

View Full Version : [CLOSED] Panel syncHeight NaN



OlleJonsson
9 Jul 2010, 1:03 AM
(Question of procedure: If this is marked "DUPE", where's the real bug to watch?)

Ext.Panel.syncHeight uses a value which can be a string as a number. Consider the local variable lsh:

Code copied from Ext JS Library 3.2.1.



syncHeight : function(){
var h = this.toolbarHeight,
bd = this.body,
lsh = this.lastSize.height,
sz;

if(this.autoHeight || !Ext.isDefined(lsh) || lsh == 'auto'){
return;
}


if(h != this.getToolbarHeight()){
h = Math.max(0, lsh - this.getFrameHeight());
bd.setHeight(h);
sz = bd.getSize();
this.toolbarHeight = this.getToolbarHeight();
this.onBodyResize(sz.width, sz.height);
}
},


Here, a "fix" which points out the problem, in the same way as the above poster handled his situation.




syncHeight : function(){
var h = this.toolbarHeight,
bd = this.body,
lsh = this.lastSize.height,
sz;
if (isNaN(lsh)) {
lsh = 'auto'; // avoiding "Invalid argument" error down the line, since lsh can be '100%'
}
if(this.autoHeight || !Ext.isDefined(lsh) || lsh == 'auto'){
return;
}


if(h != this.getToolbarHeight()){
h = Math.max(0, lsh - this.getFrameHeight()); // otherwise, we'd be in trouble here
bd.setHeight(h);
sz = bd.getSize();
this.toolbarHeight = this.getToolbarHeight();
this.onBodyResize(sz.width, sz.height);
}
},

Jamie Avins
13 Jul 2010, 10:06 AM
Can you provide a test case where this is occurring for you?

OlleJonsson
16 Aug 2010, 5:02 AM
This is now closable as "invalid".



[14:55] olleolleolle_: Did you ever trip over this, using Ext.grid.GridPanel'? http://www.sencha.com/forum/showthread.php?104097-INFOREQ-Panel-syncHeight-NaN
[14:55] • evant_ hasn't
[14:56] olleolleolle_: My "lsh" (last height) value is at "100%" here, which messes with the subtraction.
[14:57] evant_: % based heights aren't supported
[14:57] evant_: On Components...
[14:57] olleolleolle_: Perfect answer. (Let's get to work, here!)


Idea: If the debug build had guard clauses with things like 'throw new Error("100% not supported as height on a Component")', this kind of misuse could be trained away.

Jamie Avins
16 Aug 2010, 10:16 AM
Idea: If the debug build had guard clauses with things like 'throw new Error("100% not supported as height on a Component")', this kind of misuse could be trained away.
We are starting to implement this, more should be in place by 4.x to help with these types of issues.