Repository navigation
fix(gallery): stop the title bar's right-header glyphs from clipping - #968
Conversation
The copy-link and theme-toggle buttons in the gallery title bar are 40x36,
but WinUI's default Button padding (11,5,11,6) leaves only 18 DIP of content
width. Icon("\uE71B") resolves to a FontIcon at its default 20 DIP size, so
the glyph overflowed and was clipped on the right - the link icon lost its
trailing half and the moon/sun lost its right edge.
Size both glyphs to 16 DIP (what the WinUI TitleBar template already uses for
its own back and pane-toggle glyphs) and zero the button padding so the icon
is centred in the full 40x36 box with no clipping.
Verified against the live window: glyph ink is now 16x9 (link) and 15x16
(moon), centred in the button, matching the 16x10 pane-toggle glyph - versus
the previous ink that terminated exactly on the 18 DIP content boundary.
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: c2d77c16-04ec-408f-9d60-d30680e7cf2c
PR review flagged that the gallery fix now leans on the standalone
Icon(FontIcon(glyph, fontSize:)) path with nothing covering it. Two
distinct code paths carry it and neither had a live fixture:
mount - IconResolver.CreateFontIcon, which assigns FontFamily only when
the author supplied one (unlike ResolveIconString, which assigns
ResolveSymbolFontFamily() by hand). If those two ever land on
different families, typed glyph icons render tofu.
update - IconElement.PatchIcon's same-subtype patch, which rewrites Glyph
and FontSize in place.
RBC_IconElementFontIconSizing mounts the gallery's exact shape, swaps the
glyph at a constant size, then changes the size, and pins the zero padding
the fix also depends on.
Every check was mutation-verified against product code, one oracle each:
GlyphAndSizeProjected CreateFontIcon FontSize write
ExplicitFamilyWins CreateFontIcon FontFamily write
DefaultFamilyMatchesGlyphResolver ResolveSymbolFontFamily target
ZeroPaddingApplied ApplyModifiers padding write
GlyphSwapKeepsSize PatchIcon Glyph write
SizeChangePatched PatchIcon FontSize write
Each mutation failed exactly its own check and no others; src/ is reverted.
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: c2d77c16-04ec-408f-9d60-d30680e7cf2c
There was a problem hiding this comment.
Pull request overview
Fixes clipped glyph rendering in the ReactorGallery title bar right-header buttons by ensuring the icons fit within the 40×36 button content box (matching the WinUI TitleBar chrome sizing), and adds a selftest fixture to cover the typed FontIcon projection and same-subtype update patching paths.
Changes:
- Switch gallery title-bar buttons from
Icon(stringGlyph)toIcon(FontIcon(glyph, fontSize: 16))and apply.Padding(0)to avoid clipping. - Introduce
GalleryControls.TitleBarGlyphSizeconstant to centralize the chosen glyph size. - Add
RBC_IconElementFontIconSizingselftest fixture and register it in the selftest registry.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/Reactor.AppTests.Host/SelfTest/SelfTestFixtureRegistry.cs | Registers the new RBC fixture in the list and factory switch. |
| tests/Reactor.AppTests.Host/SelfTest/Fixtures/ReconcilerBigCoverageFixtures.cs | Adds IconElementFontIconSizing fixture covering mount/update paths for FontIcon sizing and padding. |
| samples/ReactorGallery/UserControls/GalleryControls.cs | Updates the deep-link copy button to use sized FontIcon + zero padding; adds TitleBarGlyphSize constant. |
| samples/ReactorGallery/GalleryShell.cs | Updates the theme toggle button to use sized FontIcon + zero padding. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
📦 Build metricsArtifact sizes for Packages (compressed .nupkg)
Assemblies in Microsoft.UI.Reactor
Assemblies in Microsoft.UI.Reactor.Advanced
Assemblies in Microsoft.UI.Reactor.Devtools
No size change beyond the noise floor. ✅ ✅ smaller / |
🧪 Merged coverageCoverage for
No coverage change beyond the noise floor. ✅ ✅ higher / |
- Replace exact double ==/!= on FontSize with a tolerance helper. A WinUI control default can be theme-resource derived rather than a literal; the 0.0001 tolerance is far tighter than any DIP gap under test (16/20/28), so it cannot mask a real mismatch. - Hoist the null guards out of the ?. chains. Once the leading conjunct proves non-null the later ?. reads were constant-true conditions, which obscured intent and tripped the constant-condition analyzer. Behaviour is unchanged and the oracles still trap: re-mutating both FontSize writes (IconResolver.CreateFontIcon and IconElement.PatchIcon) fails GlyphAndSizeProjected, GlyphSwapKeepsSize and SizeChangePatched; reverted, the whole RBC_ group is green. Co-authored-by: Copilot App <[email protected]> Copilot-Session: c2d77c16-04ec-408f-9d60-d30680e7cf2c
Second pr-review pass flagged that the comment on IconFontSize_DefaultFamilyMatchesGlyphResolver overclaimed. Under a live app SymbolThemeFontFamily is present, so ResolveSymbolFontFamily returns from its theme-resource arm; the check traps a retarget of that arm (which is what the mutation run actually exercised) but not the `?? SymbolFontFallback` tail, which never executes in this host. Rewrite the comment in the style of the existing "Scope, honestly:" note in PrivateMountHotPaths: say which arm is trapped, point at PrivMount_SymbolFontFallbackStack as the check that pins the fallback constant, and state what this check uniquely adds - cross-path agreement between Reactor's hand-assigned family and the WinUI FontIcon default style, whose divergence would render typed glyph icons as tofu while the string form kept working. Comment-only; the six checks are unchanged and still green. Co-authored-by: Copilot App <[email protected]> Copilot-Session: c2d77c16-04ec-408f-9d60-d30680e7cf2c
Refreshes the base past #968/#970/#971/#972 so CI validates this fix against current main rather than a stale base. Only DataGridEditFixtures.cs is touched by both sides; main's change there is the #971 fixed-delay -> WaitFor sweep in neighbouring fixtures and auto-merges clean. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 40080795-41cb-4886-bfa4-219bf8567dcc
Verified in the running gallery: Navigation -> TitleBar -> "TitleBar with
Content" renders its 36x36 settings button as tofu (the .notdef empty
rectangle). Windows font fallback does NOT substitute a symbol font for
U+E713 in default-font text.
Button(string) assigns the raw string to Button.Content, so it renders
through a ContentPresenter/TextBlock in the inherited FontFamily. That is a
different path from Icon(...), which goes through IconResolver and assigns
SymbolThemeFontFamily. On the very same page the two title-bar buttons
(copy-link, theme toggle) render their glyphs correctly because they take
the Icon(...) path - a clean same-window differential.
It is also an accessibility defect: the button's UIA Name was EMPTY, since
a PUA codepoint as string content yields no usable accessible name.
Fixed every site that used the broken shape:
samples/ReactorGallery/ControlPages/Navigation/TitleBarPage.cs (+ the
displayed snippet, which showed a third variant again)
docs/_pipeline/templates/windows.md.dt -> recompiled docs/guide/windows.md
docs/specs/059-titlebar-drag-regions.md
plugins/reactor/skills/reactor-windowing/SKILL.md (ships in the NuGet
agent kit, so it was teaching this to end users)
src/Reactor/Elements/ElementExtensions.cs (IsDragRegion XML doc example,
ships in IntelliSense)
All now use Icon(FontIcon("\uE713", fontSize: 16)) - the idiom microsoft#968
established - and the gallery button gains AutomationName("Settings"),
confirmed live: its UIA Name is now "Settings" instead of empty.
Deliberately NOT changed, because they are already correct:
NavItem(..., icon: "\uE713", ...) in samples/NavigationDemo, skills/figma.md
and spec 001 - the icon parameter routes through IconResolver.
Caption("\uE713") in samples/apps/chat - sets .FontFamily explicitly.
The old snippet's Button("<gear>") - U+2699 is present in normal text
fonts, so that half of the original report was wrong.
reactor-search-index.json needs no regeneration: the generator takes each
page's FIRST complete SampleCard, which for TitleBarPage is "Basic TitleBar",
not the card edited here. Verified by regenerating - no diff.
Closes microsoft#979
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: c2d77c16-04ec-408f-9d60-d30680e7cf2c
The bug
The gallery title bar's two right-header buttons rendered clipped glyphs — the link icon lost its trailing half, the moon lost its right edge.
Root cause
Both buttons are
40×36. WinUI's defaultButtonpadding is11,5,11,6, leaving 18 DIP of content width.Icon("\uE71B")resolves (viaIconResolver.ResolveIconString) to aFontIconat its default 20 DIP size, so the glyph overflowed the content box and was clipped on the right.Measured on the live window: glyph ink spanned
x:1654..1669, terminating exactly on the1653..1670content boundary — while the title bar's own back / pane-toggle glyphs render at 16 DIP.Fix
Size both glyphs to 16 DIP (what the WinUI
TitleBartemplate already uses for its own chrome) and zero the button padding so the icon centres in the full40×36box.Also verified in dark theme (the
\uE706sun arm) and for the transient "copied" checkmark state:Test
The fix moves both buttons onto the standalone
Icon(FontIcon(glyph, fontSize:))path, which had no coverage. Two distinct code paths carry it:IconResolver.CreateFontIcon, which assignsFontFamilyonly when the author supplied one, unlikeResolveIconStringwhich assignsResolveSymbolFontFamily()by hand. If those two ever land on different families, typed glyph icons render tofu.IconElement.PatchIcon's same-subtype patch, which rewritesGlyphandFontSizein place.RBC_IconElementFontIconSizingmounts the gallery's exact shape, swaps the glyph at a constant size, then changes the size, and also pins the zero padding the fix depends on.Every check was mutation-verified against product code — one oracle each. Each mutation failed exactly its own check and no others:
GlyphAndSizeProjectedCreateFontIconFontSize writeExplicitFamilyWinsCreateFontIconFontFamily writeDefaultFamilyMatchesGlyphResolverResolveSymbolFontFamilytheme-resource armZeroPaddingAppliedApplyModifierspadding writeGlyphSwapKeepsSizePatchIconGlyph writeSizeChangePatchedPatchIconFontSize writeCommits
b5a2f094a930b331f19cbd4d5468Review trail
Two full passes of the repo's
pr-reviewskill (8 dimensions each, multi-model cross-check on a different model family), plus three Copilot review rounds.b5a2f09) — 0 critical, 0 high, 1 medium: theIcon(FontIcon(..., fontSize:))path had no coverage. Closed by the fixture.DefaultFamilyMatchesGlyphResolveroverclaimed. Under a live appResolveSymbolFontFamilyreturns from its theme-resource arm, so the check traps a retarget of that arm — what the mutation run exercised — but not the?? SymbolFontFallbacktail, which never executes in this host. Comment rewritten to say so, in the style of the existing "Scope, honestly:" note inPrivateMountHotPaths.highfindings allegingButton("\uE713")renders tofu inControlPages/Navigation/TitleBarPage.csanddocs/_pipeline/templates/windows.md.dt. Both files are outside this diff, and the claim rests on Windows PUA font fallback, which is unverified — the multi-model cross-check disputed both and also found the paired⚙is U+2699, which is in normal text fonts. Filed as Verify whetherButton("\uE713")renders tofu in the TitleBar sample and the windows guide #979 instead of expanding this PR.github-code-quality[bot]raised 4 (one float-equality, three constant-condition), all fixed in31f19cb, each replied to and resolved. Rounds 2 and 3 → no new comments.Validation
--self-test --filter "RBC_"green locally; CI 18 pass / 2 skipped / 0 fail, including Selftests, AOT Selftests, AOT Trim Proof, E2E, and Docs buildsamples/ReactorGallerybuilds clean (0 errors, noREACTOR_*diagnostics)dotnet run --project tools/Reactor.SearchIndex— no drift; the generator reads onlyControlRegistry.cs,PageRouter.csandControlPages/**, none of which this touchesskills/reactor.api.txtneeds no regeneration