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

`shell.openItem` should activate the opened app #10477

Closed
sindresorhus opened this Issue Sep 9, 2017 · 4 comments

Comments

Projects
None yet
4 participants
@sindresorhus
Contributor

sindresorhus commented Sep 9, 2017

  • Electron version: 1.7.7
  • Operating system: macOS 10.12.6

Expected behavior

For example, if I ask it to open a path to a directory, it should open it in Finder and focus the Finder window.

Actual behavior

It opens the Finder window in the background and my app window is still focused.

How to reproduce

shell.openItem('path/to/some/dir/');

Focusing the opened app is expected behavior on macOS and should at least be an option.

The shell.openExternal method has this, so it's clear you agree. We just need the behavior/option added to this method too.

@MarshallOfSound

This comment has been minimized.

Member

MarshallOfSound commented Sep 9, 2017

Afaik this is because our implementation of openItem on macOS doesn't use NSWorkspace rather the now deprecated AE api's. This is due to a number of bugs with alternate implementations.

https://github.com/electron/electron/blob/master/atom/common/platform_util_mac.mm#L127

If you want to open it with activation I believe you can just pass the file path to openExternal

@sindresorhus

This comment has been minimized.

Contributor

sindresorhus commented Sep 9, 2017

/atom/common/platform_util_mac.mm@master#L127

The first mentioned issue there is fixed in Chromium. They're using NSWorkspace now: https://cs.chromium.org/chromium/src/chrome/browser/platform_util_mac.mm?l=30&rcl=975794ee43d7036fb94be988a9f6751db85c7a3a

If you want to open it with activation I believe you can just pass the file path to openExternal

Yes, that's my workaround, but it's ugly as it requires converting the path to a file URL.

@codebytere

This comment has been minimized.

Member

codebytere commented Sep 20, 2017

👋 @sindresorhus this fix is now in master, so i'm going to go ahead and close this issue!

@codebytere codebytere closed this Sep 20, 2017

@sindresorhus

This comment has been minimized.

Contributor

sindresorhus commented Sep 20, 2017

@codebytere Thank you for fixing this 🙌

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