Skip to content
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]: BrowserView setBounds behavior inconsistent between Mac and Windows #35994

Closed
nornagon opened this issue Oct 11, 2022 · 9 comments · Fixed by #38981
Closed

[Bug]: BrowserView setBounds behavior inconsistent between Mac and Windows #35994

nornagon opened this issue Oct 11, 2022 · 9 comments · Fixed by #38981
Assignees
Labels
bug 🪲 component/BrowserView status/confirmed A maintainer reproduced the bug or agreed with the feature

Comments

@nornagon
Copy link
Member

bv.setBounds({x: 0, y: 0, width: 500, height: 40})

gives different results on different platforms:

mac:
Screen Shot 2022-10-11 at 4 09 38 PM

windows:
image

Regressed in #34713 I believe. cc @codebytere

@kevinlinv
Copy link
Contributor

🎉 FYI, this may partially fix this issue #35995

@codebytere
Copy link
Member

@nornagon it behaves the same (arguably incorrect) way on Windows as it used to on macOS - i believe the solution here is to bring Windows in line with macOS rather than revert the change on Windows.

From the original issue:

Fixes an issue where part of the BrowserView could be cut off when calling setBounds on some windows. This was happening because we were not taking the titlebar height into account when calling setBounds on a framed window, which meant that the y-value for the bounds would end up negative.

This same issue happens on Windows (which I missed).

@codebytere codebytere self-assigned this Oct 12, 2022
@nornagon
Copy link
Member Author

hm... i'm not sure? I don't feel like y=0 should put the browserview underneath the titlebar. also, it's a breaking change because everyone who uses browserview would need to update their code to avoid their app breaking.

@arman-canva
Copy link

Hi, have there been any further developments with regards to this?

@StephanU
Copy link

StephanU commented Dec 2, 2022

I also think this is a breaking change introduced in the bugfix release v19.0.15:

v19.0.14...v19.0.15#diff-c540c2e05740fa476322f2d34ffc1db3d9e85d8419aa14556af6e97bad2a3611R262

@davej
Copy link
Contributor

davej commented Dec 30, 2022

Here's a hacky solution to normalize the y value on Windows and Mac (Linux not tested).

function getAdjustedY(win: BrowserWindow, y = 0) {
  const winHeight = win.getSize()[1];
  const contentHeight = win.getContentSize()[1];
  const titlebarHeight = winHeight - contentHeight;

  return process.platform === "darwin" ? titlebarHeight + y : y;
}

@RangerMauve
Copy link

RangerMauve commented Feb 13, 2023

Still seeing this in Electron 23. Ty for the fix @davej, gonna try it out.

Update: The fix worked as expected!

@dsanders11 dsanders11 added bug 🪲 component/BrowserView status/confirmed A maintainer reproduced the bug or agreed with the feature labels Apr 2, 2023
@dsanders11 dsanders11 changed the title BrowserView setBounds behavior inconsistent between Mac and Windows [Bug]: BrowserView setBounds behavior inconsistent between Mac and Windows Apr 2, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jul 2, 2023

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@github-actions github-actions bot added the stale label Jul 2, 2023
@davej
Copy link
Contributor

davej commented Jul 3, 2023

Still an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 component/BrowserView status/confirmed A maintainer reproduced the bug or agreed with the feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants