electron: [Bug]: In Mac OS Sonoma (14.0) showInactive, is not inactive anymore

Preflight Checklist

Electron Version

26.2.1

What operating system are you using?

macOS

Operating System Version

Mac OS Sonoma 14

What arch are you using?

x64

Last Known Working Electron version

No response

Expected Behavior

When window.showIncative() the focus is still on the app below the window that you just make appear. The menu is still the menu from the app below and not the menu from your app.

My window is in type: panel

Actual Behavior

When window type: panel and on window.showIncative() the electron js app becomes active, the app’s menu shows.

This wasn’t the behavior on the previous Mac OS version.

Testcase Gist URL

No response

Additional Information

No response

About this issue

  • Original URL
  • State: closed
  • Created 9 months ago
  • Reactions: 12
  • Comments: 21

Most upvoted comments

Take a look at https://github.com/abhaybuch/node-mac-window for a hacked together native module that lets you bring a window into focus without activating it’s application

We are experiencing the same issues.

Also running into this when trying to show a panel window without taking activating the application. Investigating if there’s an quick fix via native Node module. But my suspicion is that the issue is that Sonoma changed some implementation detail that caused the following lines in focus:

[[NSApplication sharedApplication] activateIgnoringOtherApps:NO];
[window_ makeKeyAndOrderFront:nil];

to start activating the application when it previously did not. The new behavior reads as more correct so we might have been relying on a bug 😬

I think the thing we need is to be able to call just makeKeyAndOrderFront, will report back if I can get it working in a test

Please fix this 😃 It is essential for certain system utility apps to not steal previous app’s activation.

@ufukomer how do you use this lib?

  1. Add to package.json:
"dependencies":  {
  "node-active-app": "github:abhaybuch/node-mac-window",
}
  1. Add types if you are using TS:
// node-active-app.d.ts
declare module 'node-active-app' {
  export function makeKeyAndOrderFront(buffer: Buffer): void;
}

  1. Instead of calling browserWindow’s show function, override it, or just call makeKeyAndOrderFront function:
import { makeKeyAndOrderFront } from 'node-active-app';

// This is how it looks like for my app but you don't have to do it, just call makeKeyAndOrderFront by passing the native window handle of your BrowserWindow as param.
show(): void {
    if (this.isLocked()) {
       iipc.send(SHOW_MAIN_WINDOW);
    } else if (!this.window.isVisible()) {
      makeKeyAndOrderFront(this.window.getNativeWindowHandle());
    } else {
      this.hide();
    }
}

And don’t forget to try my app https://copaste.app 👯 Thanks to @abhaybuch

Hey @felixrieseberg what’s up on this, I see that it was released only on 28.x.x

It is hard to find out what is going on, can you give an update 🙏