electron: .isMaximized() always returns false even when window is maximized.

  • Electron version: v1.6.2
  • Operating system: win 10

Expected behavior

.isMaximized(); should return true

Actual behavior

.isMaximized(); returns false;

How to reproduce

const $ = require('jquery');
const {remote} = require('electron');
var win = remote.getCurrentWindow();

$('body').dblclick(function(){
  console.log('double clicked!');
});

$('#minimize').click(function(){
  win.minimize();
});

$('#close').click(function(){
  win.close();
});

$('#maximize').click(function() {
  if(win.isMaximized()){
      win.unmaximize();
      console.log('unmaximized');
  }else{
      win.maximize();
      console.log('maximized');
  }
  console.log(win.isMaximized());
});

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 1
  • Comments: 31 (1 by maintainers)

Most upvoted comments

One of the problems with this not being fixed might be because of this issue being closed. The issue is definitely not resolved. I’d say that this issue should be reopened.

It has been over 2 years and this issue has still not been fixed. Hopefully, we will get one by 5.0.

I believe transparent=true is the root cause. Once the window is maximized, it will never unmaiximzed. I set my HTML window to be draggable, so that I can show the Window’s context menu, which is usually available by right clicking the original Window titlebar. Now I can see that the menu item “Maximize” (in the Window’s context menu) is by default bold. It is expected to be disabled.

(I’m using 1.7.4 beta)

it seems to be working now

@stanleyxu2005 @FullstackDevsYT Same issue

Windows 10 | Electron 1.7.x and 1.8.x


Work around:

var TMP = { maximized: true }

const remote = require('electron').remote,
      window = remote.getCurrentWindow()

if(TMP.maximized == true) {
    TMP.maximized = false
    window.unmaximize()
  } else {
    TMP.maximized = true
    window.maximize()
  }

Basic… but that’s all I needed. P.S. this expects your application to be maximized, if its not maximized by default be sure to have this instead:

var TMP = { maximized: false }

I have the same problem when I set: resizable: false Question: Why can I maximize and can not unmaximize?

@stanleyxu2005 +1,frameless window set transparent=true -> .isMaximized(); always returns false; electron: v1.7.5

In the previous version I used the following code:

  ipcMain.on('APPLICATION-MAXIMIZE', () => {
    mainWindow.isMaximized() ? mainWindow.unmaximize() : mainWindow.maximize()
  });

But in the current version it does not work anymore 😦 The code mainWindow.isMaximized() always returns FALSE

@stanleyxu2005 +1: if frameless window is set to transparent:true, win.isMaximized() will return always false. Electron 1.7.0

It has been over 2 years and this issue has still not been fixed. Hopefully, we will get one by 5.0.

Your comment just turned 4 years old and this is still a problem 😄

The problem still persists

Still issue in my app. I hope they will fix it whenever.

I agree with @Trackhe there needs to be a fix to this

However, you can determine the maximum resolution size of the application and let that determine if your window needs to be maximized or minimized/unmaximized.