You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Change default web behaviors that don't make sense in the context of Electron #12631
There are a number of behaviors that Electron inherits from Chromium which don't make sense for the vast majority of Electron apps. For instance:
dragging a file into a window navigates to that file
pinch-zooming in a window zooms the UI
Cmd+Click opens links a new BrowserWindow
Electron apps that don't want these behaviors currently have to disable them explicitly, in an ad-hoc and error-prone way. Since these behaviors are undesirable for almost every Electron app, we should disable them by default.
This issue is a tracking issue for discussion about this general idea; separate issues will be created for specific changes that need to be made.
Reacted by PalmerAL, Machisté N. Quintana, Charles Kerr, Keeley Hammond, Zhuo Lu, Heilig Benedek, Jesse Niininen, Simon Edwards, Eliot Lash, Sam Maddock and 6 more
Reacted by Jacob Groundwater, Machisté N. Quintana, Charles Kerr, Keeley Hammond, Sindre Sorhus, Tim Fish, Heilig Benedek, Eliot Lash and Vladislav Shtepin
dragging a file into a window navigates to that file
Pretty much every Electron app source I've seen manually disables this.
pinch-zooming in a window zooms the UI
I've been developing for Electron for a long time, but only recently noticed this behavior and found a way to disable it. I bet there are lots of apps with this in production without even knowing it (Even the Slack app!).
We could expose the API to set the ZoomMode of a WebContents, by default zoom is per-origin in chromium, but we already have the internal code to override that behavior (code was ported from chromium). 0f4341d
Yep, there are ways to work around all these undesirable features. But IMO, the default should be the expected behavior (don't pinch-zoom, don't navigate on drag/drop, etc.) and apps that want those features should have to explicitly enable them.
@timfish I agree that layout zoom (i.e. Cmd++) should remain enabled by default. Visual zoom mostly results in people accidentally doing it and not knowing what happened, though, leading to weird bug reports :)
acceptFirstMouse Boolean (optional) - Whether the web view accepts a single mouse-down event that simultaneously activates the window. Default is false.
Hmm, I'm not sure I agree—on macOS at least, clicking on most native apps when they're not focused brings the window to the front without causing a mouse-click on whatever it was you clicked on. Clicking a button in a background window requires two clicks. (Perhaps it's different on other OSes though? We could change the default to be OS-specific.)
I was digging through google and issues to find out how to enable pinch-zoom, and only got tons of results on how to disable it, suggesting it's enabled by default.
I finally found this issue (which is still open!) and #12679, it would be nice to have this change documented somewhere more visible.
(At least i couldn't find anything yet)
Is the latter still supported? so far i only had success using webFrame. If not, a reference to webFrame would be helpful too. Until I researched on this had no idea what the 'web-frame' renderer export is or why it exists, because there was no reference to it in webContents nor BrowserWindow docs (or anywhere else it seems. though the search is not that reliable). Even now i have no clue why we have webFrame and webContents.
In terms of the default behavior, shouldn't we provide different presets like "browser-like" (e.g. use electron as web site wrapper or use electron as hackable web browser) or "app-like" (e.g. only show bundled HTML/JS to build native app like UX)? Then using the former preset can keep the existing behavior like "Cmd+Click opens links a new BrowserWindow".
I think just changing the default behavior would make it difficult/error-prone to create browser-like experience instead. Also it would be nice to keep Chrome's behavior where possible especially for newcomers with mental models like "electron is just a web browser with hackable API"
Rendering untrusted content in Electron is still somewhat uncharted territory, though some apps are finding success (e.g. Beaker Browser).
So I would assume we should not completely ignore "using electron as hackable web browser" use case, which is also currently I am personally experimenting with.
Seven years on and I'm trying to make a tutorial video on the mac for our app and this useless behavior keeps ruining my takes. There is no way out of it so I have to scrap the take, reset my app, and start again -- hoping it doesn't happen again. It's a totally useless feature from which there is no escape other than to restart the application.
Activity
sindresorhus commentedon Apr 17, 2018
Pretty much every Electron app source I've seen manually disables this.
I've been developing for Electron for a long time, but only recently noticed this behavior and found a way to disable it. I bet there are lots of apps with this in production without even knowing it (Even the Slack app!).
timfish commentedon Apr 17, 2018
setVisualZoomLevelLimitsdisables pinch zooming. Most production Electron apps I've checked already do this.setZoomFactorandsetLayoutZoomLevelLimitsdisable zoom scaling which should probably be left enabled for accessibility reasons.brenca commentedon Apr 17, 2018
We could expose the API to set the
ZoomModeof aWebContents, by default zoom is per-origin in chromium, but we already have the internal code to override that behavior (code was ported from chromium).0f4341d
nornagon commentedon Apr 17, 2018
Yep, there are ways to work around all these undesirable features. But IMO, the default should be the expected behavior (don't pinch-zoom, don't navigate on drag/drop, etc.) and apps that want those features should have to explicitly enable them.
@timfish I agree that layout zoom (i.e. Cmd++) should remain enabled by default. Visual zoom mostly results in people accidentally doing it and not knowing what happened, though, leading to weird bug reports :)
timfish commentedon May 3, 2018
How about
BrowserWindowoptionacceptFirstMouse:I think the default should be true.
nornagon commentedon May 3, 2018
Hmm, I'm not sure I agree—on macOS at least, clicking on most native apps when they're not focused brings the window to the front without causing a mouse-click on whatever it was you clicked on. Clicking a button in a background window requires two clicks. (Perhaps it's different on other OSes though? We could change the default to be OS-specific.)
timfish commentedon May 3, 2018
ah yes you're right and it looks like
acceptFirstMouseis a macOS only option.On Windows, Electron already accepts first mouse by default. 👍
nornagon commentedon May 29, 2018
Images (and perhaps other elements, like
<a>tags?) should be non-draggable by default.nornagon commentedon May 29, 2018
Possibly, text should be non-selectable by default? i.e.
user-select: none.remmycat commentedon Dec 14, 2018
I was digging through google and issues to find out how to enable pinch-zoom, and only got tons of results on how to disable it, suggesting it's enabled by default.
I finally found this issue (which is still open!) and #12679, it would be nice to have this change documented somewhere more visible.
(At least i couldn't find anything yet)
nornagon commentedon Dec 14, 2018
I agree, but I'm not sure where to add that documentation! Where were you expecting to find it? That's probably the best place to put it :)
remmycat commentedon Dec 15, 2018
Hm, i mostly looked at
https://electronjs.org/docs/api/web-frame#webframesetvisualzoomlevellimitsminimumlevel-maximumlevel (this is where the defaults should be listed i think)
and https://electronjs.org/docs/api/web-contents#contentssetvisualzoomlevellimitsminimumlevel-maximumlevel
Is the latter still supported? so far i only had success using webFrame. If not, a reference to webFrame would be helpful too. Until I researched on this had no idea what the 'web-frame' renderer export is or why it exists, because there was no reference to it in webContents nor BrowserWindow docs (or anywhere else it seems. though the search is not that reliable). Even now i have no clue why we have webFrame and webContents.
anaisbetts commentedon Feb 14, 2019
I am extremely Into all of these things 💖
gdavidkov commentedon Nov 21, 2019
Hi,
is zoom still per-origin?
naruaway commentedon Nov 29, 2021
In terms of the default behavior, shouldn't we provide different presets like "browser-like" (e.g. use electron as web site wrapper or use electron as hackable web browser) or "app-like" (e.g. only show bundled HTML/JS to build native app like UX)? Then using the former preset can keep the existing behavior like "
Cmd+Clickopens links a new BrowserWindow".I think just changing the default behavior would make it difficult/error-prone to create browser-like experience instead. Also it would be nice to keep Chrome's behavior where possible especially for newcomers with mental models like "electron is just a web browser with hackable API"
In addition to that, the official electron doc on sandbox is mentioning
So I would assume we should not completely ignore "using electron as hackable web browser" use case, which is also currently I am personally experimenting with.
fix: disable pinch zoom gestures
grantcv1 commentedon Mar 27, 2025
Seven years on and I'm trying to make a tutorial video on the mac for our app and this useless behavior keeps ruining my takes. There is no way out of it so I have to scrap the take, reset my app, and start again -- hoping it doesn't happen again. It's a totally useless feature from which there is no escape other than to restart the application.