Skip to content

MudProgressCircular: Calculate view box size based on stroke width#11557

Merged
ScarletKuro merged 3 commits intoMudBlazor:devfrom
Anu6is:11550-ProgressCircular-DynamicViewBox
Jun 28, 2025
Merged

MudProgressCircular: Calculate view box size based on stroke width#11557
ScarletKuro merged 3 commits intoMudBlazor:devfrom
Anu6is:11550-ProgressCircular-DynamicViewBox

Conversation

@Anu6is
Copy link
Contributor

@Anu6is Anu6is commented Jun 26, 2025

Description

Currently the view box size remains static while the stroke width value can be changed. This can result in a stroke width that eventually renders the circle outside the bounds of the view box. This PR adjusts the view box size based on the value of the stroke width.

Resolves #11550

How Has This Been Tested?

Visually and Unit test

Type of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (fix or improvement to the website or code docs)

image
image
image

Checklist

  • The PR is submitted to the correct branch (dev).
  • My code follows the code style of this project.
  • I've added relevant tests.

@github-actions github-actions bot added the bug Unexpected behavior or functionality not working as intended label Jun 26, 2025
@codecov
Copy link

codecov bot commented Jun 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.20%. Comparing base (b3a94fc) to head (2993594).
Report is 1 commits behind head on dev.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev   #11557   +/-   ##
=======================================
  Coverage   91.20%   91.20%           
=======================================
  Files         466      466           
  Lines       14688    14697    +9     
  Branches     2855     2855           
=======================================
+ Hits        13396    13405    +9     
  Misses        646      646           
  Partials      646      646           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR ensures that the SVG viewBox of MudProgressCircular dynamically adjusts when the StrokeWidth changes, preventing the circle from being clipped.

  • Calculates a new viewBox in OnParametersSet based on StrokeWidth
  • Updates the Razor markup to use the computed _viewBox instead of a static value
  • Adds unit tests to verify correct viewBox values across stroke widths

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/MudBlazor/Components/Progress/MudProgressCircular.razor.cs Compute _viewBox dynamically in OnParametersSet
src/MudBlazor/Components/Progress/MudProgressCircular.razor Bind SVG viewBox attribute to the computed _viewBox
src/MudBlazor.UnitTests/Components/ProgressCircularTests.cs Add and correct tests for viewBox logic and existing test cases
src/MudBlazor.UnitTests.Viewer/TestComponents/Progress/MudProgressCircularWidthTest.razor Provide a live demo for variable StrokeWidth in the test viewer
Comments suppressed due to low confidence (2)

src/MudBlazor.UnitTests/Components/ProgressCircularTests.cs:158

  • Consider adding a test case for a negative StrokeWidth (e.g., -5) to validate that the Math.Max(0, StrokeWidth) guard correctly treats negatives as zero and produces the same viewBox.
        [TestCase(0, "24 24 40 40")]

src/MudBlazor/Components/Progress/MudProgressCircular.razor.cs:21

  • Replace the hard-coded MagicNumber with a computed circumference (e.g., int circumference = (int)(2 * Math.PI * CircleRadius)) or rename it to something like Circumference to avoid magic numbers and make future radius changes safe.
        private const int MagicNumber = 126; // weird, but required for the SVG to work

@mckaragoz
Copy link
Member

Yeah, this was one of the known bug. Happy to see this PR.

@sonarqubecloud
Copy link

@ScarletKuro ScarletKuro merged commit 76c1e52 into MudBlazor:dev Jun 28, 2025
6 checks passed
@Anu6is Anu6is deleted the 11550-ProgressCircular-DynamicViewBox branch June 28, 2025 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Unexpected behavior or functionality not working as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MudProgressCircular: Increasing StrokeWidth cuts all sides of the progress indicator

4 participants