Repository navigation
Center the update count text inside the sidebar badge - #5574
Merged
Gabriel Dufresne (GabrielDuf) merged 1 commit intoOct 22, 2026
Merged
Conversation
The badge TextBlock was centered with HorizontalAlignment="Center" and the default left TextAlignment. That centers the TextBlock's layout box, whose desired width layout rounding pushes up to the device-pixel grid (a 9px bold digit is just over 5 DIP, so the box becomes 6 DIP at 100%). The glyph is then drawn left-aligned inside that box, so all of the rounding slack lands on its right and the number sits about 1 DIP left of center at 100-125% and one physical pixel left at 200%. Using TextAlignment="Center" with the default Stretch alignment lets the TextBlock fill the Border's content width and the text formatter center the line on its real, unrounded advance width, splitting the slack evenly. Stretch only affects arrange, so the Border still measures to its content and keeps the same widths (16, 17 and 23 DIP for one digit, two digits and "99+"), leaving the MinWidth circle and the negative-right-margin clipping fix untouched. SidebarUpdateBadgeTests renders the real SidebarView headlessly and asserts the gap before and after the text line is equal for counts 3, 42 and "99+" at scalings 1, 1.25, 1.5 and 2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused alignment change has targeted regression coverage and no identified blocking issues.
No open issues 🎉
What changed in this PR
Corrects horizontal centering of the available-updates count in UniGetUI’s sidebar badge without changing its sizing rules.
Changes:
- Centers the text within the badge rather than centering the TextBlock’s layout box.
- Adds seven headless regression cases covering single-digit, two-digit, and “99+” counts at multiple display scales.
| File | Description |
|---|---|
src/UniGetUI.Tests/SidebarUpdateBadgeTests.cs |
Adds layout assertions that verify equal horizontal gaps around the update count. |
src/UniGetUI.Avalonia/Views/SidebarView.axaml |
Replaces horizontal control alignment with centered text alignment. |
Review effort: Balanced
There was a problem hiding this comment.
🤖 Pull request was approved automatically: the AI review is complete and all its review threads are resolved. 🎉
Integration Details
{
"deliveryId": "766b2f40-ce1f-11f1-83ce-5269b3d9f175",
"headSha": "0a45d1a975b53bcc4188a373f2dd1c73612b76dc",
"reviewer": "copilot-pull-request-reviewer[bot]"
}
Gabriel Dufresne (GabrielDuf)
deleted the
fix/nav-update-badge-text-off-center
branch
October 22, 2026 14:30
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug report
There is no GitHub issue; the maintainer reported this directly. The number on the available-updates badge in the navigation bar is not quite centered. It sits a pixel or two too far to the left.
Root cause
The badge
TextBlockinSidebarView.axaml(inside the update-countBorder) usedHorizontalAlignment="Center"with the defaultTextAlignment=Left. That centers the TextBlock's layout box in the Border's 10 DIP content area, not the text itself. Layout rounding rounds the box's desired width up to the device-pixel grid. At 9px bold Segoe UI a digit is just over 5 DIP wide, so the box becomes 6 DIP at 100%. The box is centered, but the glyph is drawn left-aligned inside it, so all the rounding slack ends up on the right.In a headless Skia render with Segoe UI, the left/right ink gaps for a single digit were 5.0/6.0 DIP at 100%, 4.8/6.4 at 125% and 5.0/6.0 at 200%. That is about 1 DIP left of center at 100-125% and one physical pixel at 200%, which matches the report. The global
TextTrimming=CharacterEllipsisstyle plays no part: the measurements were the same without it.Fix
HorizontalAlignment="Center"is replaced withTextAlignment="Center"on the badgeTextBlock. The TextBlock now uses its default Stretch alignment and fills the Border's content width. The text formatter centers the line on its real, unrounded advance width, so the slack is split evenly on both sides.Stretch only affects arrange, not measure, so the Border still sizes to its content. The widths are unchanged: 16 DIP for one digit, 17 for two, 23 for "99+". The
MinWidthcircle and the negative-right-margin clipping fix are not affected. After the change, single-digit left/right ink gaps are within about 0.3 DIP at every scale from 100% to 200% (for example 5.5/5.5 at 200%, 5.6/5.6 at 125%). Two-digit counts and "99+" are within one rendered pixel.Regression test
UniGetUI.Tests.SidebarUpdateBadgeTests.UpdateCountIsHorizontallyCenteredInItsBadgerenders the realSidebarViewheadlessly withUpdatesBadgeCountset at a given render scaling. It finds the badgeTextBlockand asserts that the gap from the Border's left edge to the start of the text line equals the gap from the end of the line to the Border's right edge, within 0.01. It covers counts 3, 42 and 150 ("99+") at scalings 1, 1.25, 1.5 and 2.Verification
dotnet build UniGetUI.Avalonia.csproj -p:Platform=x64 -p:UseSharedCompilation=false: exit 0, 0 errors. The 18 warnings are pre-existing ones in files this change does not touch.FullyQualifiedName~SidebarUpdateBadgeTests): 7 of 7 pass with the fix. WithSidebarView.axamlreverted, 2 of 7 fail (count 3 at scaling 1: left gap 4, right gap 3; count 3 at scaling 1.25: left 3.2, right 3.8).dotnet format whitespaceanddotnet format stylewith--verify-no-changes, on the new test file: both exit 0. The.axamlchange is not processed by the C# formatters.Review notes (non-blocking)
dotnet format style src/UniGetUI.Windows.slnx --verify-no-changesexits 2 on IDE0060 atsrc/UniGetUI.PackageEngine.Tests/CargoManagedOperationRoutingTests.cs:155. That warning comes from main (Replace Cargo helper tools with native C# package management #5569), not this diff, but the CI style check may fail on this PR because of it.HorizontalAlignment="Center"plus left-aligned text pattern. They were not audited.🤖 Generated with Claude Code