fix: preserve size constraints across maximise/unmaximise cycle#5204
Conversation
DisableSizeConstraints() was overwriting the original MinWidth/MinHeight/ MaxWidth/MaxHeight option values with 0, so EnableSizeConstraints() could never restore them. This caused ToggleMaximise and UnMaximise to permanently lose window size constraints. Save the original constraint values before zeroing and restore from saved values when re-enabling constraints. Fixes #4593
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughWebviewWindow now saves min/max width and height when size constraints are disabled and restores those saved values when constraints are re-enabled, using saved fields and a constraintsSaved flag. ChangesSize Constraint Persistence
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Tested on Windows 11 Pro 24H2 (Build 26100) — verdict: ✓ pass
Test results:
The save/restore logic correctly guards with PR test pass on Windows (go1.26.2 / WebView2 147.0.3912.98 / amd64) |
|
Good bug fix! Losing size constraints after maximise/unmaximise is a real issue for applications that need strict window sizing. The save/restore pattern is correct. I've dispatched cross-platform test sub-issues:
Once all platforms report back with successful test results, I'll apply the CC @leaanthony |
|
Investigating on Windows 11 Pro (24H2, Build 26100). Test environment: Go 1.26.2 · WebView2 147.0.3912.86 Unit tests ( Both constraint-save/restore tests pass on Windows. The CC @leaanthony |
Summary
DisableSizeConstraints()was overwritingMinWidth/MinHeight/MaxWidth/MaxHeightoptions with 0 via the platform impl, soEnableSizeConstraints()could never restore themToggleMaximise()orUnMaximise(), min/max window constraints were permanently lostsavedMinWidth/savedMinHeight/savedMaxWidth/savedMaxHeightbefore zeroing; restore from saved values on re-enableTest plan
TestDisableSizeConstraintsSavesValuesverifies values are saved before zeroingTestRestoreAfterZeroingOptionsverifies saved values can restore the originalsTestDisableSizeConstraintsDoesNotOverwriteSavedValuesverifies saved values survive options being zeroedFixes #4593
Summary by CodeRabbit