Ext.NET icon indicating copy to clipboard operation
Ext.NET copied to clipboard

Ext.ux.desktop.Desktop shortcut 'restores' windows even if initially maximized

Open fabriciomurta opened this issue 6 years ago • 1 comments

Found: 4.8.1 Ext.NET forums' thread: Desktop window from short cut not getting maximized and if there is a TopBar its covering the top bar

This issue is similar to #1565, but triggers only and only if the window is bound to be displayed via a desktop shortcut.

To reproduce the issue, just add Maximized="true" to the GridWindow module (WebForms location, MVC location) in the Desktop example (WebForms, MVC).

Then, when opening the desktop's GridWindow icon (double click it), it will be easily noticed how the window goes from maximized to its would-be initial width-height ("restored" state).

The animation below ilustrates the scenario: 62644-desktop_wnd_maximized

fabriciomurta avatar May 17 '19 19:05 fabriciomurta

The least invasive override I could think of would disable the desktop's restoreWindow() method while the maximized window is about to be created:

Ext.define('gh1640', {
    override: 'Ext.ux.desktop.Desktop',
    onShortcutItemClick: function (dataView, record) {
        var me = this,
            module = me.app.getModule(record.data.module),
            win = module && module.createWindow(),
            restoreWindowFn;

        // Tamper away the 'restoreWindow' method if the window is
        // maximized, so that calls to it are "ignored" while opening
        // it, if window is to be initially maximized.
        if (win.maximized) {
            restoreWindowFn = me.restoreWindow;
            me.restoreWindow = Ext.emptyFn;
        }

        me.callParent(arguments);

        // Bind back restoreWindow() if it was moved away during the
        // open process.
        if (Ext.isFunction(restoreWindowFn)) {
            me.restoreWindow = restoreWindowFn;
        }
    }
});

Which is equivalent to remove the original method's restoreWindow() call in the condition win.maximized.

fabriciomurta avatar May 17 '19 19:05 fabriciomurta