fix: update shell.openExternal to correctly focus on external window (#44468)

fix: update shell.openExternal to correctly focus on external window (#44408)

* fix: Use openURL:configuration:completionHandler instead of openUrl

* test: add a test

* fix: add dispatch_async to replace GetUIThreadTaskRunner

* refactor: remove unused import

* fix: update to use BindPostTaskToCurrentDefault

* test: add regression test for window focus

* refactor: update to explicit task runner

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Alice Zhao <alice@makenotion.com>
This commit is contained in:
trop[bot] 2024-10-31 12:05:51 +01:00 committed by GitHub
parent 4f13824bc9
commit 4507774c51
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 36 additions and 4 deletions

View file

@ -76,6 +76,21 @@ describe('shell module', () => {
requestReceived
]);
});
ifit(process.platform === 'darwin')('removes focus from the electron window after opening an external link', async () => {
const url = 'http://127.0.0.1';
const w = new BrowserWindow({ show: true });
await once(w, 'focus');
expect(w.isFocused()).to.be.true();
await Promise.all<void>([
shell.openExternal(url),
once(w, 'blur') as Promise<any>
]);
expect(w.isFocused()).to.be.false();
});
});
describe('shell.trashItem()', () => {