Repository navigation
Fix DevTools size and spacing explanations for margins and fixed widths - #1171
Zach Teutsch (zateutsch) wants to merge 4 commits into
Conversation
The Size & spacing panel compared DesiredSize (includes Margin, capped at available space) with RenderSize (excludes Margin, keeps explicit Width), so margins were reported as constraints and fixed widths told users to check MaxWidth. Compare like with like, explain clipped fixed widths, and redraw the section when the element's layout changes. Fixes #1146 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 27aaf273-a2b8-4931-a462-a0646e7f6496
There was a problem hiding this comment.
🟡 Changes recommended
Pending property reads can leave explanations stale, and margin edge cases still produce incorrect clipping warnings or negative offered widths.
3 open issues
What changed in this PR
This PR updates DevTools’ Size & spacing panel to account for margins, explain oversized fixed widths, and refresh when the selected element’s layout changes.
Changes:
- Compares desired and rendered widths with consistent margin handling.
- Explains when a fixed Width exceeds the available space.
- Adds throttled layout updates that replace only the Size & spacing section, plus regression checks.
| File | Description |
|---|---|
src/winapp-devtools/test/window-runtime-tests.cpp |
Adds margin, fixed-width, and layout-comparison checks. |
src/winapp-devtools/native/WinApp.DevTools.Native/DevToolsWindow.State.inc |
Stores the layout snapshot used by the pane. |
src/winapp-devtools/native/WinApp.DevTools.Native/DevToolsWindow.PropsPane.inc |
Captures that snapshot when displaying a selection. |
src/winapp-devtools/native/WinApp.DevTools.Native/DevToolsWindow.PropsLayout.inc |
Revises margin labels and width explanations. |
src/winapp-devtools/native/WinApp.DevTools.Native/DevToolsWindow.LiveProps.inc |
Watches layout changes and refreshes the section selectively. |
Review effort: Balanced
Build Metrics ReportValidation passed. All required build and validation jobs succeeded. Binary Sizes
.NET Test Results (TRX reports)Other suites are reflected in the overall validation status above. ✅ 10669 passed, 43 skipped out of 10712 tests in 1781.3s (+5.0s vs. baseline) Test Coverage✅ 87.4% line coverage, 81.5% branch coverage · ✅ no change vs. baseline CLI Startup Time55ms median (x64, Try This BuildInstalls the MSIX for your architecture, replacing any previously installed build. Needs the GitHub CLI — the command offers to install it and sign you in if it is missing. & ([scriptblock]::Create((irm https://raw.githubusercontent.com/microsoft/winappCli/main/scripts/winapp-pr.ps1))) 1171Switching between builds often?Put the tool on your PATH once: & ([scriptblock]::Create((irm https://raw.githubusercontent.com/microsoft/winappCli/main/scripts/winapp-pr.ps1))) -AddToPathThen this build is just: winapp-pr 1171Run Updated 2026-10-24 00:01:44 UTC · commit |
Negative margins or a margin wider than the slot no longer produce false clipping warnings or negative offered widths. Changing Margin, Width, MinWidth, MaxWidth, Padding, BorderThickness or HorizontalAlignment now redraws the explanation even when the geometry is unchanged. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 27aaf273-a2b8-4931-a462-a0646e7f6496
|
Agent came back with 2 points of feedback. I believe both existed before this PR so I can file as separate issues to tackle later or you can address here. Lmk which route you want to go with. Approving in the interim: Size & spacing can show old padding after an editWhat is wrong: Changing Padding in DevTools can update the app control and its Padding property row without updating the Size & spacing diagram. How to reproduce: Select a Border control with fixed Width Why it happens: The edit updates the property row before the live refresh checks it. The refresh sees no difference, and the control’s unchanged outer size also prevents a diagram redraw. Smallest fix: Refresh Size & spacing after a spacing-property edit, even when the property row already shows the new value. Verification: The skipped-refresh code path was reproduced in an executable probe. The visible behavior has not yet been confirmed in a running app. Changing parent spacing can leave old parent details displayed
|
Editing Padding, Margin or a width property now redraws the section even though the live refresh later sees the row already updated. Layout comparison also covers parent spacing, padding, orientation, grid cell and actual size, so changing only those no longer leaves stale details. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 27aaf273-a2b8-4931-a462-a0646e7f6496
|
Chiara Mooney (@chiaramooney) Fixed both here in 48bc3f9, since they're in the live-refresh code this PR adds: editing Padding (or Margin, Width, etc.) now redraws Size & spacing right away, and changing only the parent's Spacing, Padding, orientation or Grid cell now redraws it too. Tests added for both. |
…ze-spacing-explanations

What and why
The DevTools Size & spacing panel gave the wrong explanation in two common cases. It also didn't update when the window was resized.
Margin="10"was told "It got MORE width than it asked for, so something is stretching it". The margin was being counted as part of the asked-for size but not the size it got.Width="400"in a 275-pixel slot, and no MaxWidth set, was told "Check MaxWidth". The real problem is that it's wider than its parent and gets clipped.With this change:
Fixes #1146
Before / after
Explanation text for a
Width="400"element inside a 275-pixel slot (from the native window tests):Before
After
For an element with
Margin="10"and no constraint, the panel no longer claims something is stretching it.Not tested / risks
Checklist
.\src\winapp-devtools\build-devtools.ps1 -Arch arm64passed, with 461 of 461 native dispatcher checks and 112 of 112 native window checksNotes for reviewers
The cause: the panel compared
DesiredSizewithRenderSize.DesiredSizeincludes the margin and is capped at the space the parent offers.RenderSizeleaves out the margin and keeps an explicit Width even when it overflows. The fix adds the margin to the size the element got before comparing, and floors the result at zero.To keep the panel current, it subscribes to
LayoutUpdatedand checks again after 250 ms. It redraws only if the layout numbers changed, so animation doesn't redraw it every frame.