Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: toggleDevTools menu role closes devtools window #29922

Merged
merged 1 commit into from
Aug 2, 2021
Merged

Conversation

nornagon
Copy link
Member

Description of Change

Fixes #28770.

webContents.getOwnerBrowserWindow() when called on a devtools webcontents
seems to return the BrowserWindow containing the webContents to which the
devtools is attached.

This probably doesn't work great for windows with BrowserViews in them, but
then, the previous implementation of this also didn't work correctly for that
case, so it's probably fine?

Checklist

Release Notes

Notes: Fixed detached DevTools window not closing when a menu item with the toggleDevTools role was triggered.

@nornagon nornagon added no-backport semver/patch backwards-compatible bug fixes labels Jun 28, 2021
@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Jun 28, 2021
@pushkin-
Copy link

In my original issue, I don't use any menus. Will this fix still work for that?

@nornagon
Copy link
Member Author

nornagon commented Jun 28, 2021

@pushkin- unfortunately no, Electron doesn't provide any non-Menu APIs for registering accelerators across the whole app. I think that could be a useful extension to the globalShortcut module, but that's beyond the scope of this PR. See #1334, #20964, and workarounds like https://github.com/parro-it/electron-localshortcut.

@@ -143,7 +143,10 @@ export const roleList: Record<RoleId, Role> = {
label: 'Toggle Developer Tools',
accelerator: isMac ? 'Alt+Command+I' : 'Ctrl+Shift+I',
nonNativeMacOSRole: true,
windowMethod: w => w.webContents.toggleDevTools()
webContentsMethod: wc => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we test this? We should be able to trigger the role and then check isDevToolsOpened() i'd imagine?

@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Jun 29, 2021
@zcbenz zcbenz merged commit 888ac65 into main Aug 2, 2021
@zcbenz zcbenz deleted the toggle-devtools branch August 2, 2021 01:58
@release-clerk
Copy link

release-clerk bot commented Aug 2, 2021

Release Notes Persisted

Fixed detached DevTools window not closing when a menu item with the toggleDevTools role was triggered.

BlackHole1 pushed a commit to BlackHole1/electron that referenced this pull request Aug 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-backport semver/patch backwards-compatible bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request]: Provide API for auto toggling devtools when a key is pressed
4 participants