Search code examples
javascriptextjsextjs4positionextjs4.2

ExtJS 4.2 - Constrained window is not positioned correctly after maximizing and then restoring


I have a window inside a panel with constrainHeader:true and maximizable:true. I'm using ExtJS 4.2.1.883. When the window is maximized, it expands to fill the panel as expected. When the window is restored, however, it does not return to it's previous position and is instead positioned slightly higher than expected.

See jsFiddle here.

To reproduce, click the 'add window' button, maximize the window, and then restore it. I expect that this issue is due to the header and/or toolbar but am not sure how to accommodate for that.


Solution

  • I ended up just overriding the maximize method for Ext.window.Window. There's a line where the window calculates the position it should be restored to. I changed that as follows:

    //me.restorePos = me.getPosition(true);
    me.restorePos = me.getPosition();
    

    From the docs:

    getPosition( [local] ) : Number[] Gets the current XY position of the component's underlying element.

    Available since: 4.0.0

    Parameters local : Boolean (optional) If true the element's left and top are returned instead of page XY.

    Defaults to: false

    This may cause different issues in some situations, but I have not noticed any problems in my application so I'm going with it for now. Updated jsFiddle with full override here.