reactjsmacosbrowserelectron

Electron window.open() opens all windows on macos only


I have an electron app which can open a child window when in main window I receive a call. When this window is shown and main window is minimized, only the child window must be shown. It works exactly like that on Windows but on macos the app opens all the windows. Why this might be happening?

Thank you.

Unfortunately, I can't share much code. Here how I open a child window ** renderer.tsx**

const externalWindow = window.open("", "IncomingWindow"); //Portal window

main.ts

mainWindow.webContents.setWindowOpenHandler(({ frameName }) => {
    if (frameName === "IncomingWindow") {
      return {
        action: "allow",

        overrideBrowserWindowOptions: {
          parent: mainWindow,
          width: 700,
          height: 115,
          y: 40,
          x: getScreenCenter() - 230,
          center: true,
          alwaysOnTop: true,
          title: "call-window",
          resizable: false,
          minimizable: false,
          paintWhenInitiallyHidden: true,
          show: true,
          maximizable: false,
          frame: false,
          
          
          autoHideMenuBar: true,
          skipTaskbar: true,
          transparent: true,
          hasShadow: true,
        },
      };
    } else {
      return { action: "deny" };
    }
  });

I tried multiple configurations for the child window but the behaviour hasn't changed.


Solution

  • Ok, I just figured it out... The key is to remove parent: mainWindow from the configuration.