You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My WinForms app can manage multiple windows with WebView2 controls navigated to pages from the same web application. Sometimes the JavaScript code running in these pages has UI-adjustment code that depends on the size and position of the window. But if that code runs very early in the page lifecycle, the window object's position properties (screenLeft/screenX and screenTop/screenY) return 0 instead of the actual position they should. If that logic runs after an asynchronous delay, then the values it sees are accurate.
Then the two subsequent alert dialogs will report (0, 0) followed by numbers that match the window's actual position. C# code inspecting the window's Form's position before running that script agrees that the numbers should not be (0, 0).
I have a couple workarounds I can use for this issue, but they're both pretty ugly, and reorganizing the web app's logic to avoid reading the position too early would be a big undertaking.
(The window's position is also affected by this issue, but I have a separate workaround for it.)
Importance
Moderate. My app's user experience is affected, but still usable.
Click the Launch Second Window button to launch a window in which the script code will run.
Observe the position values reported in alert dialogs in the new window.
The first alert should say the window is at (0, 0) when it should instead be in the middle of your screen. The second alert will report a position that is more or less in agreement with the window's real position.
Repros in Edge Browser
No, issue does not reproduce in the corresponding Edge version
Regression
Don't know
Last working version (if regression)
No response
The text was updated successfully, but these errors were encountered:
What happened?
My WinForms app can manage multiple windows with WebView2 controls navigated to pages from the same web application. Sometimes the JavaScript code running in these pages has UI-adjustment code that depends on the size and position of the window. But if that code runs very early in the page lifecycle, the
window
object's position properties (screenLeft
/screenX
andscreenTop
/screenY
) return 0 instead of the actual position they should. If that logic runs after an asynchronous delay, then the values it sees are accurate.For example, if the startup code looks like this:
Then the two subsequent alert dialogs will report (0, 0) followed by numbers that match the window's actual position. C# code inspecting the window's
Form
's position before running that script agrees that the numbers should not be (0, 0).I have a couple workarounds I can use for this issue, but they're both pretty ugly, and reorganizing the web app's logic to avoid reading the position too early would be a big undertaking.
(The window's position is also affected by this issue, but I have a separate workaround for it.)
Importance
Moderate. My app's user experience is affected, but still usable.
Runtime Channel
Stable release (WebView2 Runtime)
Runtime Version
131.0.2903.99
SDK Version
2535.41
Framework
Winforms
Operating System
Windows 11
OS Version
22631.4602
Repro steps
WrongJSWindowLocation.zip
The first alert should say the window is at (0, 0) when it should instead be in the middle of your screen. The second alert will report a position that is more or less in agreement with the window's real position.
Repros in Edge Browser
No, issue does not reproduce in the corresponding Edge version
Regression
Don't know
Last working version (if regression)
No response
The text was updated successfully, but these errors were encountered: