electron: [Bug]: Setting resizable to false disables dragging of custom drag regions

Preflight Checklist

Electron Version

14.0.0

What operating system are you using?

Windows

Operating System Version

Windows 10 Pro - 20H2 - 19042.1165 - Windows Feature Experience Pack 120.2212.3530.0

What arch are you using?

x64

Last Known Working Electron version

13.2.2

Expected Behavior

When creating a new, frameless BrowserWindow setting resizable: false should not change the behaviour of custom app drag regions defined using -webkit-app-region: drag;.

Actual Behavior

When creating a new, frameless BrowserWindow with the test scenario in the Gist (using Electron Fiddle) the region I’ve defined as draggable using -webkit-app-region: drag; does not allow me to drag the BrowserWindow if resizable is set to false.

You can see the difference by commenting/uncommenting the resizable: false line in the Electron Fiddle Gist example.

Testcase Gist URL

https://gist.github.com/68a75365505163c4a19ab19c5ffd062a

Additional Information

Just to note that I’ve also tried using win.setResizable(false); after the BrowserWindow has loaded and this then also disables the ability to drag the frameless BrowserWindow. Using the following code also then re-enables dragging after 5 seconds so the bug seems directly tied to the BrowserWindow not being resizable.

setTimeout(() => {
  mainWindow.setResizable(true);
}, 5000);

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 25
  • Comments: 17 (3 by maintainers)

Commits related to this issue

Most upvoted comments

As a workaround, you can simply set the min and max sizes to prevent the resize from doing anything (same intent as resizable: false, but will show the cursor for resize).


const width  = 1280;
const height = 720;

let mainWindow = new BrowserWindow({
    width    : width,
    height   : height,
    minWidth : width,
    minHeight: height,
    maxWidth : width,
    maxHeight: height,
    resizable: true
    ...

Thanks for including the gist! I was able to reproduce the issue.

This seems to be caused by a combination of changes from #29721 and #29600.

The logic that checks for resizing is called prior to draggable region checks: https://github.com/electron/electron/blob/e6802bf93597b61cb9235a63681c0ed57cc018cb/shell/browser/ui/views/frameless_view.cc#L88-L97

The resize hit test always returns early if the window is not resizable: https://github.com/electron/electron/blob/e6802bf93597b61cb9235a63681c0ed57cc018cb/shell/browser/ui/views/frameless_view.cc#L42-L46

@MarshallOfSound This will have some serious effects on out use case, which was relying on a fixed-size window and custom draggable regions. The PR linked does not really provide any insight into how exactly this is expected behaviour, only a discussion around how to address resizing handles. Am I missing something here?

Hoping this decision could be revisited, as this is functionality is critical to our use case, and the proposed fix seemed at least mostly reasonable

I believe there may be some confusion here as to the conclusion of #30809, admittedly it’s 2am here atm so I’ll take a better look in the morning, but re-reading that discussion my understanding is now that the referenced expected behavior does not explicitly disallow a fix for the behavior this report describes. I agree that this current behavior is unexpected.

I have a suspicion that https://github.com/electron/electron/pull/30925 might fix this but no promises

Critical for me as well. Just as a workaround - downgraded to 13.3.0. Works fine.

@MarshallOfSound I’m not sure I understand. So we now can’t have custom drag regions without having a resizeable app? Are you suggesting that this functionality has been broken from the start and has only now been ‘fixed’?

This is causing severe issues for our app running on Electron 13.5.1, enabling resizable is not an option. Please fix this ASAP or reach out if you require additional information. (Enabling “resizable: true” makes the drag region work again)

Same issue affects us on Windows. However, macOS works fine. (electron v13.5.0)

What worked for us as a workaround is keeping resizeable true but setting the maxWidth/maxHeight to the desired values. Only problem with it is that the cursor will still indicate resize.