electron: Can't close browser window when detached devtools window is opened (electron 10)
Preflight Checklist
- I have read the Contributing Guidelines for this project.
- I agree to follow the Code of Conduct that this project adheres to.
- I have searched the issue tracker for an issue that matches the one I want to file, without success.
Issue Details
- Electron Version:
v10.0.0-beta.21
- Operating System:
Windows 10 (1909)
- Last Known Working Electron version:
v9.1.0
Expected Behavior
If I have a browser window and a detached devtools window for that opened, then I can close the browser window and the devtools window closes also.
Actual Behavior
I can’t close the browser window. I have to manually close the detached devtools window first, then I can close the browser window.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 10
- Comments: 29 (5 by maintainers)
Commits related to this issue
- fix: Used `ready-to-show` event to prevent frameless window issues See also: https://github.com/electron/electron/issues/25012#issuecomment-829045916 — committed to cawa-93/vite-electron-builder by cawa-93 3 years ago
- fix: Used `ready-to-show` event to prevent frameless window issues See also: https://github.com/electron/electron/issues/25012#issuecomment-829045916 — committed to fanly/fanlymenu by cawa-93 3 years ago
- fix: Used `ready-to-show` event to prevent frameless window issues See also: https://github.com/electron/electron/issues/25012#issuecomment-829045916 — committed to fanly/fanlymenu by haoduanduan 3 years ago
- fix: Used `ready-to-show` event to prevent frameless window issues See also: https://github.com/electron/electron/issues/25012#issuecomment-829045916 — committed to fanly/fanlymenu by fanly 3 years ago
In case if you are handling the close in Windows may be below can help,
const currentWindow = window.require(‘electron’).remote.getCurrentWindow(); if (currentWindow.isDevToolsOpened()) { currentWindow.closeDevTools(); } currentWindow.close();
Thank you @Treverix for bringing this up! Different to you, I dont see the problem with v10.x but I can confirm this bug exists in v11.0, v11.1, v11.2 on Windows.
This is unfortunately the major issue prevents me to upgrade projects to latest Electron, until I created my version of workaround:
Include it, call it and enjoy it!
fix for me was to set
show: false, and then onready-to-showevent show the window, after that if devtools opened window closes as expected and without delayelectron version 12.0.2
Finally I found the cause and it’s an error in electron. This show the problem w/o a custom library. To reproduce:
frame: falseon the browser window optionscloseButtonStart the app, open the dev tools (any mode).
Expected behavior: if we click the button on the screen, the window is closed
Observed behavior if we click the button on the screen, the window is not closed. We need to close the devtools first.
Hope that helps!
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, “bump”), and we’ll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
It seem to have been fixed in 13.2.1. Can anyone check?
I can confirm this issue. Electron v12.0.5. Windows.
BrowserWindow with
autoHideMenuBar: trueorframe: falsedoest close if devTools opened (detached or attached).The window does not close either with native system controls or on call
require('@electron/remote').getCurrentWindow().close().Workarounds that work for me:
Same issue for me with Electon 11.3.0 and frame = false. I used also the function to fix the problem…but I also need to call window.destroy(). If I create the electron application in staging or production, this problem doesn’t occur.
Wow. This is an excellent solution in a temporary development environment