Skip to content

Commit 370c8d6

Browse files
committed
make it actually work
1 parent e42fe99 commit 370c8d6

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src-main/windows/editor.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,12 @@ class EditorWindow extends ProjectRunningWindow {
249249
};
250250

251251
this.window.webContents.on('will-prevent-unload', () => {
252-
// Using showMessageBoxSync immediately within the event handler breaks focus on
253-
// Windows - https://github.com/TurboWarp/desktop/issues/1245.
254-
// Instead, we'll let the window refuse the unload, then show our own prompt after
255-
// the event finishes and manually close it ourselves instead of relying on Electron.
256-
queueMicrotask(() => {
252+
// Using showMessageBoxSync synchronously in the event handler causes broken focus on Windows.
253+
// See https://github.com/TurboWarp/desktop/issues/1245
254+
// To work around that, we'll let the will-prevent-unload event happen so the window stays open,
255+
// then show our own prompt after a very short delay so that window focus doesn't break.
256+
257+
setTimeout(() => {
257258
const choice = dialog.showMessageBoxSync(this.window, {
258259
title: APP_NAME,
259260
type: 'info',
@@ -270,7 +271,7 @@ class EditorWindow extends ProjectRunningWindow {
270271
if (choice === 1) {
271272
this.window.destroy();
272273
}
273-
})
274+
});
274275
});
275276

276277
this.window.on('page-title-updated', (event, title, explicitSet) => {

0 commit comments

Comments
 (0)