electron: [Bug]: setMinimumSize refreshes BrowserWindow after a delay

Preflight Checklist

Electron Version

11.1.0

What operating system are you using?

Windows

Operating System Version

10

What arch are you using?

x64

Last Known Working Electron version

No response

Expected Behavior

I set a window’s minimum size to be greater than the current size. I expect the BrowserWindow to increase in immediately size to match the new minimums.

Actual Behavior

The window takes some time to increase in size

Testcase Gist URL

No response

Additional Information

const { app, BrowserWindow } = require('electron')

async function createWindow() {
	const mainWindow = new BrowserWindow({ width: 500, height: 500 });
	mainWindow.setMinimumSize(700, 700); // size only increases to this after moving the window
}

app.on('ready', createWindow)

gif

continuation of this closed issue

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Comments: 22 (3 by maintainers)

Most upvoted comments

Workaround:

function setMinimumWindowDimensions(win, minWidth, minHeight) {
	win.setMinimumSize(minWidth, minHeight);

    const { width, height } = win.getBounds();
    win.setBounds({
        width: Math.max(width, minWidth),
        height: Math.max(height, minHeight)
    });
}