electron: setSize can't shrink non-resizable window (but can grow it)
- Output of
node_modules/.bin/electron --version: v3.0.7 - Operating System (Platform and Version): Windows 7
- Output of
node_modules/.bin/electron --versionon last known working Electron version (if applicable): v3.0.3
Expected Behavior mainWindow.setSize can be used to resize a window, regardless if resizable argument is true or false.
Actual behavior The very first time setSize is used, the window can be shrank. After that, it can only grow. If the intended behavior is to not allow for resizing at all, then it shouldn’t be able to grow.
To Reproduce
$ git clone https://github.com/CorySanin/electron-quick-start
$ npm install
$ npm start
Clicking the resize button several times will illustrate the problem.
Additional Information I can reproduce the growing part on Ubuntu, but can’t get the initial shrink to work. Also, I think this only affects versions 3.0.4 and up. 3.0.3 seemed to work as expected.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 7
- Comments: 15 (2 by maintainers)
Commits related to this issue
- bump version numbers can't update electron until electron/electron#15560 is resolved — committed to CorySanin/Kitten-for-CSGO by CorySanin 5 years ago
- finding a way to overcome https://github.com/electron/electron/issues/15560 — committed to mrnoplay/mrnoplay by scris 4 years ago
Workaround for this issue, is to call
setMinimumSizewith the target height and with before callingsetSize.I can confirm this is happening on Electron 8.2.0, I created a simple Electron Fiddle to demonstrate.
A workaround I found working is to use
setBounds({ width, height })instead ofsetSize(width, height).The Electron version reported on this issue is no longer supported. See our supported versions documentation.
If this is still reproducible on a supported version, please open a new issue with any other new information that a maintainer should know.
Thank you for taking the time to report this issue and helping to make Electron better! Your help is appreciated.
thank you very much, not perfect but very smart idea
This is still a problem.
if any having trouble with this… their are things that you should know.
if the browser window is in maximized or full screen
setSizewill not work. so to do so you have to unmaximize it first. sample code:I confirmed it is related to #15038. In Windows/Linux platform, we have this piece of code for no-resizable window
So as soon as we change the size, the min, max are resetted to the current size.
According to #15038 code
If it is no more possible to resize less than min size.
In a nutshell, we can always increase the size of the window, never decrease ! This case is not covered by unit tests.
It would be interesting to see if we can remove this NativeWindow::SetBounds specific code.
Meanwhile, I would suggest to revert #15038, negative side effect is far more critical than benefit.