fix: prevent window focus when clicking close/minimize buttons #69
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
When users click the close (X) or minimize button on a background window, the window is brought to the foreground before the action executes. This creates a jarring user experience where windows "jump" to the front, disrupting the user's visual context and making the interface feel unresponsive to their intent.
Steps to Reproduce
Expected Behavior
When a user clicks the close or minimize button on a window, the window should execute the requested action without first being brought to the foreground or changing focus. The current window focus and z-order should remain unchanged.
Solution
Added an early return check in the global mousedown event handler for window activation when the click target is a close or minimize button. This prevents
focusWindow()from being called on these buttons while still allowing the button's click handler to execute normally.Changes
Modified Files
src/gui/src/initgui.js(lines 1228-1230)Technical Details
The fix adds a check using jQuery's
.closest()method to detect if the mousedown event occurred on a close or minimize button (or any child element of these buttons). If detected, the handler returns early before callingfocusWindow().This follows the existing pattern already used in the codebase for excluding taskbar and popover clicks from window activation.
Testing
Manual Testing Performed
Acceptance Criteria
Impact
Benefits
Risk Assessment
Additional Notes
This fix addresses a common UX complaint in windowed interfaces and brings the behavior in line with standard operating system window managers.