Skip to content

MudStepper: Fix final step completed color#11012

Merged
henon merged 4 commits intoMudBlazor:devfrom
Lewis-Pitman:MudStepper-Fix-completed-last-step-color
Mar 15, 2025
Merged

MudStepper: Fix final step completed color#11012
henon merged 4 commits intoMudBlazor:devfrom
Lewis-Pitman:MudStepper-Fix-completed-last-step-color

Conversation

@Lewis-Pitman
Copy link
Contributor

Description

When the MudStepper is linear, the final step will now show the completed colour once completed.

Originally, it was impossible for the last step in a linear MudStepper to show the completed step color, as the last step was also the current step. This has been fixed so that if the MudStepper is linear and the last step has been completed, the current step color changes to the completed step color. The current step color is restored if the user resets the progress of the stepper.

This behaviour doesn't happen in a non linear MudStepper, as these allow you to go back and view other steps when all steps have been completed, and so having a different colour representing the current step is necessary.

Resolves #10962

How Has This Been Tested?

No tests have been added. The code does not alter existing code, and functions as expected on MudBlazor.Docs.Server

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)

MudStepper_final_step_complete_color

Checklist

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

Fixed final step's completed color. When the MudStepper is linear, the final step will now show the completed colour once completed.
@github-actions github-actions bot added bug Unexpected behavior or functionality not working as intended PR: needs review labels Mar 13, 2025
@codecov
Copy link

codecov bot commented Mar 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.01%. Comparing base (3ad7450) to head (e59bca4).
Report is 3 commits behind head on dev.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev   #11012   +/-   ##
=======================================
  Coverage   91.01%   91.01%           
=======================================
  Files         429      429           
  Lines       13943    13946    +3     
  Branches     2695     2696    +1     
=======================================
+ Hits        12690    12693    +3     
  Misses        648      648           
  Partials      605      605           

☔ 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.

@ScarletKuro ScarletKuro requested a review from henon March 13, 2025 22:31
Copy link
Contributor

@Anu6is Anu6is left a comment

Choose a reason for hiding this comment

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

There should be a new test to confirm that the final step color is actually updated once completed


private async Task SetCurrentStepColorAsync(Color color)
{
CurrentStepColor = color;
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't set CurrentStepColor directly, calling SetValueAsync should be enough.

Copy link
Contributor Author

@Lewis-Pitman Lewis-Pitman Mar 14, 2025

Choose a reason for hiding this comment

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

Hi, just took a quick look during my lunch break. Only using SetValueAsync doesn't seem to be working here. Have I implemented it wrong?

image

Edit: I think I know the solution, will implement when I can

Copy link
Member

@ScarletKuro ScarletKuro Mar 14, 2025

Choose a reason for hiding this comment

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

Hi, just took a quick look during my lunch break. Only using SetValueAsync doesn't seem to be working here. Have I implemented it wrong?

All places that used CurrentStepColor needs to be replaced with _currentStepColor.Value like this place:

.AddClass($"mud-{Parent?.CurrentStepColor.ToDescriptionString()}", Parent?.ActiveStep == this)

if it's parent component then Parent?.GetState(x => x.CurrentStepColor).

/// </summary>
[Parameter]
[Category(CategoryTypes.List.Behavior)]
public EventCallback<Color> CurrentStepColorChanged { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this EventCallback necessary?

@Lewis-Pitman
Copy link
Contributor Author

Lewis-Pitman commented Mar 13, 2025

Hi, thanks for the review. This is my first PR so I was mainly trying to follow the existing style. I'll look into implementing what you've said when I can.

_currentStepColor = registerScope.RegisterParameter<Color>(nameof(CurrentStepColor))
.WithParameter(() => CurrentStepColor)
.WithEventCallback(() => CurrentStepColorChanged)
.WithChangeHandler(async args => await SetCurrentStepColorAsync(args.Value));
Copy link
Member

Choose a reason for hiding this comment

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

just make it

.WithChangeHandler(SetCurrentStepColorAsync);
private async Task SetCurrentStepColorAsync(ParameterChangedEventArgs<Color> color)

Modifies CssBuilder instead of changing the current colour parameter
@Lewis-Pitman
Copy link
Contributor Author

I've changed how this works. Instead of changing the current colour parameter, I modified the condition for the CssBuilder. A step will display the completed colour either if it is not currently active, or if all steps have been completed and it is linear.

Thoughts on this?

Also, should I add a test for this? It says in contributing.md under "What does not need to be tested?" that the appearance of components does not need to be tested.

Fixed when completed color isn't set but a different current color is set.
@Lewis-Pitman
Copy link
Contributor Author

Sorry, just noticed after pushing that the same bug happens if you don't set a completed color but change the current step color. This new push fixes that

@ScarletKuro
Copy link
Member

ScarletKuro commented Mar 15, 2025

Also, should I add a test for this?

I think in this case a test would be nice
rest looks good to me

@Lewis-Pitman
Copy link
Contributor Author

Also, should I add a test for this?

I think in this case a test would be nice
rest looks good to me

Great, I'll look at implementing this.

Should I worry about the failing check? It's happening because the Parent? Null check isn't necessary, but it does follow the existing style

@ScarletKuro
Copy link
Member

It's happening because the Parent? Null check isn't necessary, but it does follow the existing style

Leave as is

Copy link
Contributor

@henon henon left a comment

Choose a reason for hiding this comment

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

Great! This can be merged once we have a test case that fails if you undo your fix and passes if you add it back in.

Added a test to ensure the last step has it's completed color if it is linear, and does not have the current color if a completed color was not set.
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
E Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@Lewis-Pitman Lewis-Pitman requested a review from henon March 15, 2025 15:09
@henon henon merged commit 2e29e04 into MudBlazor:dev Mar 15, 2025
5 of 6 checks passed
@henon
Copy link
Contributor

henon commented Mar 15, 2025

Thanks @Lewis-Pitman

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.

MudStepper: Color of last step is not changing if completed

4 participants