PDA

View Full Version : [FIXED-121][3.0 rev 5038] Window Resize event fires twice



thesilentman
12 Aug 2009, 12:07 PM
Ext version tested:

Ext 3.0____ rev 5038___


Adapter used:

ext


css used:

only default ext-all.css




Browser versions tested against:

FF3 (firebug 1.4.2 installed)


Operating System:

Vista Ultimate


Description:

The window resize event fires twice. It also fires always with events like maximize and restore, which I don't find to be wrong as the window is actually "resized" after these operations.


Test Case:



/*
* ! Ext JS Library 3.0+ Copyright(c) 2006-2009 Ext JS, LLC [email protected]
* http://www.extjs.com/license
*/
Ext.onReady(function() {
var win;
var button = Ext.get('show-btn');

button.on('click', function() {
// create the window on the first click and reuse on
// subsequent clicks
if (!win) {
win = new Ext.Window({
applyTo : 'hello-win',
layout : 'fit',
width : 500,
height : 300,
closeAction : 'hide',
plain : true,
resizable : true,
maximizable : true,

items : new Ext.TabPanel({
applyTo : 'hello-tabs',
autoTabs : true,
activeTab : 0,
deferredRender : false,
border : false
}),
listeners : {
resize : function(object, newWidth,
newHeight) {
console.debug('resized',
object, newWidth,
newHeight);
},
maximize : function(object) {
console.debug('maximized',
object);
},
restore : function(object) {
console.debug('restored',
object);
}
},

buttons : [{
text : 'Submit',
disabled : true
}, {
text : 'Close',
handler : function() {
win.hide();
}
}]
});
}
win.show(this);
});
});


Steps to reproduce the problem:

Just replace the hello.js in the examples/window folder with the test case code and run the hello.html example in firefox with firebug installed. You'll see that the resize event fires twice.


The result that was expected:

resize event should fire once



The result that occurs instead:

resize event fires twice



Debugging already done:

none


Possible fix:

not provided

Animal
12 Aug 2009, 12:18 PM
Yes, it's Window.handleResize.

The code is currently as below. The red comments are added by me.



handleResize : function(box){
var rz = this.resizeBox;
if(rz.x != box.x || rz.y != box.y){
this.updateBox(box);
}else{
this.setSize(box); // <-- setSize of BoxComponent fires the resize event
}
this.focus();
this.updateHandles();
this.saveState();
this.doLayout();
this.fireEvent('resize', this, box.width, box.height); // <-- so this should not be here
},

thesilentman
12 Aug 2009, 12:50 PM
I saw the handleresize but didn't follow up on the boxcomponent....
I wrote an override for handleResize leaving out the fireEvent.

Greetings,
Frank

mjlecomte
12 Aug 2009, 7:59 PM
Yeah, both parts of the if/else block call setSize which fires the event if a resize occurs.

evant
13 Aug 2009, 7:52 AM
Fixed in SVN r5051.