New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Calling .center() on BrowserWindow with parent now centers relative to parent instead of screen #41956
Comments
Hello! To add to this, I'm seeing a few differences in behavior between MacOS and Windows on child windows.
If it's manageable, I think this would be cool to parameterize in some way |
Looks like this might be an upstream-instigated change, as our Windows implementation hasn't changed in ~6 years: electron/shell/browser/native_window_views.cc Line 1073 in 76f7bbb
|
Good news and bad news: I found the CL that caused this after a quick sprint through Chromium: https://chromium-review.googlesource.com/c/chromium/src/+/4916277, but the CL indicates the previous behavior was unintended and that the new behavior (centering relative to parent) is correct and intended in the method we call. I'll see what the potential options are, as we should ensure the end-user experience remains the same as it was and adheres to expectations from documentation. |
@yangannyx if you could, it'd be helpful to make this:
its own issue! |
@codebytere, I actually see there's existing electron documentation that describes the drag behavior discrepancy here. I'm leaning towards not opening an issue for this reason, since it doesn't seem like a regression |
Preflight Checklist
Electron Version
30.0.1
What operating system are you using?
Windows
Operating System Version
Windows 10 Pro 22H2 19045.4291
What arch are you using?
x64
Last Known Working Electron version
27
Expected Behavior
As per documentation for .center() : "Moves window to the center of the screen.".
https://www.electronjs.org/docs/latest/api/browser-window#wincenter
Actual Behavior
When a BrowserWindow has a parent window defined, calling .center() on the child centers the window relative to the parent, not the screen.
Testcase Gist URL
https://gist.github.com/yangannyx/277e71dc348b289cde39e94b4b59d683
Additional Information
This issue does not exist in 27.3.11 but DOES exist in 28.0.0 onwards.
Credit to yangannyx for creating the gist in response to my initial query regarding this on discord.
The text was updated successfully, but these errors were encountered: