fix: prevent Windows tray blur→hide race on window show (#3064)#3082
Open
marceli1404 wants to merge 1 commit into
Open
fix: prevent Windows tray blur→hide race on window show (#3064)#3082marceli1404 wants to merge 1 commit into
marceli1404 wants to merge 1 commit into
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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