Skip to content

With Developer Tools open, -webkit-app-region:drag does not work #3647

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

Closed
bengotow opened this issue Dec 1, 2015 · 36 comments · Fixed by #26361
Closed

With Developer Tools open, -webkit-app-region:drag does not work #3647

bengotow opened this issue Dec 1, 2015 · 36 comments · Fixed by #26361

Comments

@bengotow
Copy link
Contributor

bengotow commented Dec 1, 2015

This is a regression—in Electron 0.35.1, draggable regions of the window stop working when the developer tools are opened. This means that the window effectively can't be moved while the developer tools are open. It doesn't matter if the developer tools are docked or in a separate window.

I think this might be a side effect of an intentional change? In previous versions, you couldn't use the "Inspect Element" feature to click and select part of the DOM that was in a draggable region (since it was still draggable.) That now works (I can hover over and click on my title bar), but I can't move the window.

Here's a sample app to reproduce. Open the app, enable "top toolbar" and then open the developer tools:

image

https://dl.dropboxusercontent.com/u/4803975/frameless-window.zip

@zcbenz
Copy link
Contributor

zcbenz commented Dec 2, 2015

This is a side effect of #3163.

@tommoor
Copy link
Contributor

tommoor commented Jun 7, 2016

This seems to be more of an issue now that the titleBarStyle behaviour was changed to not have the top area draggable by default

@mariotacke
Copy link

mariotacke commented Oct 11, 2016

Not sure if this was fixed but it works for me now (electron 1.4.2) with dev-tools open on Windows. Note, it is important to set the width and height, otherwise it would not work. Also, this only works when dragging from within the regular top area.

...
win = new BrowserWindow({
  frame: false
});
...
...
<head>
  <style media="screen">
    html, body {
      -webkit-app-region: drag;
      width: 100%;
      height: 100%;
    }
  </style>
</head>
...

@bpasero
Copy link
Contributor

bpasero commented Nov 5, 2016

It works for me on Windows too, but not sure if it was ever broken there. I can reproduce on Mac all the time.

@jonniedarko
Copy link

still an issue on os x 10.11.6 with Electron 1.6.2 using either frame: false or titleBarStyle: 'hidden'

@donpark
Copy link

donpark commented Mar 24, 2017

Issue confirmed on macOS Sierra with Electron 1.6.4.

This issue should be at least documented if not fully resolvable in the near term due to low priority.

@preco21
Copy link
Contributor

preco21 commented Apr 4, 2017

I can confirm this issue still on latest version of macOS Sierra 10.12.4 and Electron 1.6.4.

@tommoor
Copy link
Contributor

tommoor commented Apr 4, 2017

A workaround for those that are affected by this long standing bug - if you hover the mouse over the top edge of the window until you see a resize cursor and then hold and drag to the side instead of up and down to resize it will let you move the window.

@Hum4n01d
Copy link

I made a PR to add a note about this to the documentation #9155

@wierli
Copy link

wierli commented Jul 18, 2017

It not working on win10 , The native titlebar always displaying.

@Kilian
Copy link
Member

Kilian commented Dec 9, 2017

An alternative workaround is using https://github.com/kapetan/electron-drag.

edit: as of electron 4 this also no longer seems to work :(

ramfox added a commit to qri-io/2017-frontend that referenced this issue Apr 30, 2018
Needed so that the app can be moved in electron mode. There is an electron bug, however, that does not allow you to move the app when chrome DevTools is docked to the left, bottom, or right. electron/electron#3647 for more info, but for now, you can either open the inspector in a seperate windown, or close the inspector when you need to move the app
martinheidegger added a commit to dat-ecosystem-archive/dat-desktop that referenced this issue Jun 12, 2018
martinheidegger added a commit to dat-ecosystem-archive/dat-desktop that referenced this issue Jun 12, 2018
@wells1013
Copy link

Mac
electron 7.1.7
-webkit-app-region: drag

move window not work after called setSize

@caprice
Copy link

caprice commented Dec 25, 2019

I have the same issue. Current window can be dragged to everywhere freely, but it doesn't work when i try to resize current window(remote.getCurrentWindow().setSize())

@yaddran
Copy link

yaddran commented Jan 6, 2020

Mac
electron 7.1.7
-webkit-app-region: drag

move window not work after called setSize

If someone needs a workaround you can, in JS, switch style of a drag element to no-drag and after a small timeout to drag again. If you do this to one element the window will reinit the dragging of every element and magically all will work again.

@bpasero
Copy link
Contributor

bpasero commented Jan 6, 2020

@yaddran how exactly does that work?

@yaddran
Copy link

yaddran commented Jan 6, 2020

@yaddran how exactly does that work?

Well depending on the framework (or no framework) you use in the renderer process you need to change the element style from JavaScript (you can even use pure DOM and setTimeout). So, you set the style to no-drag, then do the setSize and then use setTimeout to schedule change of the element style back to drag (after 500 milli for instance). The window will resize and very soon after that the new drag will kick in and the browser will re-apply it to all elements that have drag, including the one that you are changing.

@bpasero
Copy link
Contributor

bpasero commented Jan 6, 2020

@yaddran I see. I was hoping this trick would also just fix the issue where using the mouse will no longer move the window, but I tried it and it does not help for that case.

@yaddran
Copy link

yaddran commented Jan 6, 2020

@yaddran I see. I was hoping this trick would also just fix the issue where using the mouse will no longer move the window, but I tried it and it does not help for that case.

@bpasero
Well... that is exactly what I am saying. It did solve the issue for me. Now even if I resize the window from the main process (this gets luckily triggered from the renderer process via ipc) my window is still movable with the mouse. I have discovered this by just changing the drag to no-drag and back in the developer tools. The window suddenly could again be moved with mouse... so I just programmed it in JS and it worked. Maybe you can first try this... apply no-drag on the element from developer tools, then change it to drag again and see if the window becomes movable with the mouse. If that is the case then my patch (I hope to remove it soon however) should work.

@bpasero
Copy link
Contributor

bpasero commented Jan 7, 2020

@yaddran can you possibly come up with a sample hello world electron app to show this?

@Kilian
Copy link
Member

Kilian commented Jan 7, 2020

I tried @yaddran's suggestion for the initial issue with devtools open, but unfortunately it doesn't fix it for that case.

@bpasero
Copy link
Contributor

bpasero commented Jan 10, 2020

Will #21704 fix this actually?

@pfrazee
Copy link
Contributor

pfrazee commented Jan 10, 2020

@bpasero interested to find out!

@Kilian
Copy link
Member

Kilian commented Jan 22, 2020

#21704 is in the release 7.1.9, so I tried it out and no luck.

@pfrazee
Copy link
Contributor

pfrazee commented Jan 22, 2020

@Kilian confirmed in my projects as well

@aaBaO
Copy link

aaBaO commented Feb 2, 2020

Hi, here is a problem.

  1. I set a custom div -webkit-app-region: drag first
  2. Use a menu item in main process send a message to renderer process
  3. Set my my custom div -webkit-app-region:no-drag

My div can't be undraggable, but it works what if open the dev tools, or it works after I
update my frame.

Is there a way to make it work immediately?

@blakewatson
Copy link

A workaround for those that are affected by this long standing bug - if you hover the mouse over the top edge of the window until you see a resize cursor and then hold and drag to the side instead of up and down to resize it will let you move the window.

For me, this workaround actually works on any edge. For example, position your mouse cursor at the right edge until the resize pointer appears. Then, move your mouse cursor vertically instead of horizontally. You will then be able to move the window in any direction.

@muneebbug
Copy link

Had this issue on electron v 14.0.1 and 15.0.0 beta releases but downgrading to v ^13.0.0 solved my issue

@EnterVPL
Copy link

I have the same problem with drag

System: Windows 10
Node v14.17.6
Electron 14.0.1

@muneebbug
Copy link

I have the same problem with drag

System: Windows 10
Node v14.17.6
Electron 14.0.1

Try downgrading to electron v 13.0.0

@EnterVPL
Copy link

I have the same problem with drag

System: Windows 10
Node v14.17.6
Electron 14.0.1

Try downgrading to electron v 13.0.0

I got 13.3.0 version and drag is working ❤❤❤

urz9999 added a commit to Noovolari/leapp that referenced this issue Oct 6, 2021
…apabilities

this address the electron v14 onward drag issue: electron/electron#3647
@Wehaveall
Copy link

Why the option -webkit-app does not show to me when writing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.