CodeBeamOrg / CodeBeam.MudBlazor.Extensions

Useful third party extension components for MudBlazor, from the contributors.

Home Page:https://mudextensions.codebeam.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MudStepper PreventStepChangeAsync send index of clicked/selected MudStep

rf-0 opened this issue · comments

commented

With mudstep there are 2 ways of navigating, through the Action buttons at the bottom or through the Step icons at the top. If you have validation on a per step basis and the user tries to use the Step icons at the top to jump to a later step, it is hard to validate this without knowning which Step the user clicked / is trying to navigate to. At the moment PreventStepChangeAsync only tells the direction and if you do a _stepper!.GetActiveIndex() it returns the current index and theres no way to know which index the user is trying to jump to. This isnt a problem with the bottom Action buttons navigation since it will always be the next step. If you try to do the validation on the ActiveStepChanged which happens afterwards PreventStepChangeAsync , it is already too late and even if you validate and call SetActiveStepByIndex(), you still get a flash screen (not ideal...) since its basically rendering the step the user clicked and then sending the user back to the one set by SetActiveStepByIndex.

Solution:

PreventStepChangeAsync

[Parameter] public Func<StepChangeDirection, **int SelectedIndex**, Task<bool>> PreventStepChangeAsync { get; set; }

+1 - Just came across the exact same challenge trying to validate step changes.

Added a TargetIndex parameter into PreventStepChangeAsync. Please note that it's a breaking change and you need to add the new int parameter to your component's func.

Fantastic, thank you :)