fix: preserve window bounds on reload to prevent resize on Windows#1511
Open
Aditya2073 wants to merge 1 commit into
Open
fix: preserve window bounds on reload to prevent resize on Windows#1511Aditya2073 wants to merge 1 commit into
Aditya2073 wants to merge 1 commit into
Conversation
When the app window is snapped to half screen (Windows Snap) and Ctrl+R is pressed in dev mode, webContents.reload() causes the Electron window to lose its snapped position and resize to full width. This is a known Electron bug (#25359). Fix: save window bounds before reloading and restore them when the page finishes loading. Fixes responsively-org#999 Co-Authored-By: Claude <noreply@anthropic.com>
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.
Description
When the app window is snapped to half screen using Windows Snap and Ctrl+R is pressed (or View → Reload is used), the Electron window loses its snapped position and resizes to full width. This is caused by a known Electron bug (#25359).
Fix
Save the window bounds (position and size) before calling
webContents.reload(), then restore them when the page finishes loading via thedid-finish-loadevent.Changes
desktop-app/src/main/menu/view.ts: In the dev-mode reload handler, savemainWindow.getBounds()before reload and restore them viamainWindow.setBounds()afterdid-finish-loadfires.Testing
yarn buildyarn test(69 tests, 14 files)Notes
webContents.reload()). In production mode, the reload sends an IPC message to reload individual webview tags, which does not reload the BrowserWindow and should not trigger this issue.isDevis true, so it has no impact on production behavior.Fixes #999