Skip to content

fix: prevent Windows tray blur→hide race on window show (#3064) - #3082

Closed
marceli1404 wants to merge 1 commit into
gitify-app:mainfrom
marceli1404:fix/windows-tray-blur-race
Closed

fix: prevent Windows tray blur→hide race on window show (#3064)#3082
marceli1404 wants to merge 1 commit into
gitify-app:mainfrom
marceli1404:fix/windows-tray-blur-race

Conversation

@marceli1404

Copy link
Copy Markdown

Problem

Issue #3064: On Windows v7.0.0/v7.0.1, clicking the tray icon produces no visible result. The app runs in background (notifications, colored icon) but the window never appears. Silent failure — no errors in logs.

Root Cause

\�lectron-menubar's internal blur handler hides the window 100ms after it loses focus. On Windows, clicking the tray icon may not transfer focus to the window, causing the blur→hide timeout to fire immediately after \showWindow(). When this timeout fires before the first paint cycle, the user sees no visible result.

Relevant Menubar.ts code:
\\ ypescript
this._browserWindow.on('blur', () => {
if (!this._browserWindow) return;
this._browserWindow.isAlwaysOnTop()
? this.emit('focus-lost')
: (this._blurTimeout = setTimeout(() => {
this.hideWindow();
}, 100));
});
\\

If \�lwaysOnTop\ is true, the blur handler emits \ ocus-lost\ instead of hiding — this is the escape hatch.

Fix

Listen for the \�fter-show\ event and temporarily set \�lwaysOnTop=true\ for 400ms after showing the window. This causes the blur handler to short-circuit via the \ ocus-lost\ path instead of hiding. The user's \keepWindowOnBlur\ preference is restored after the blur race window passes.

Fixes #3064

…3064)

On Windows, clicking the tray icon may not transfer focus to the window,
triggering electron-menubar's internal blur handler which hides the window
after a 100ms timeout. If this timeout fires before the first paint, the
user sees no visible result.

Workaround: listen for 'after-show' and temporarily set alwaysOnTop=true
so the blur handler emits 'focus-lost' instead of hiding. Restore the
user's preference after 400ms.
@github-actions github-actions Bot added the bug Something isn't working label Jul 26, 2026
@afonsojramos

Copy link
Copy Markdown
Member

I was not quite able to reproduce on the windows machines I had access to, but hopefully this got addressed in the electron-menubar dependency.

@marceli1404

Copy link
Copy Markdown
Author

Thanks for checking, @afonsojramos. The fix hooks into the �fter-show event and temporarily sets �lwaysOnTop: true for 400ms so the blur handler emits ocus-lost instead of calling hideWindow(). This works regardless of whether �lectron-menubar upstream has been updated, since it patches the behavior at the BrowserWindow level.

If you have a Windows machine available to test, the key scenario is: left-click or right-click the tray icon — the window should appear and remain visible instead of silently disappearing. Without the fix, the window flashes briefly and vanishes.

@afonsojramos

Copy link
Copy Markdown
Member

We are the maintainers of the dependency, so the fix is easy to apply :)

@setchy

setchy commented Jul 27, 2026

Copy link
Copy Markdown
Member

Thanks everyone! 🙇 A good workaround.

I'm hopeful that electron fixes this themselves in a future release. I recall reading something about windows blur behavior changing, but wasn't expecting this type of regression.

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

Labels

bug Something isn't working

Development

Successfully merging this pull request may close these issues.

Unable to open window

3 participants