Skip to content

Commit c4b6e9b

Browse files
committed
Fix ComponentBaseTests.
Check if ValueChanged.HasDelegate. internal FluentWizard in FluentWizardStep
1 parent b9a109d commit c4b6e9b

3 files changed

Lines changed: 24 additions & 5 deletions

File tree

src/Core/Components/Wizard/FluentWizard.razor.cs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,11 @@ protected virtual async Task OnNextHandlerAsync(MouseEventArgs e)
187187
if (!isCanceled)
188188
{
189189
Value = targetIndex;
190-
await ValueChanged.InvokeAsync(targetIndex);
190+
if (ValueChanged.HasDelegate)
191+
{
192+
await ValueChanged.InvokeAsync(targetIndex);
193+
}
194+
191195
StateHasChanged();
192196
}
193197
}
@@ -210,7 +214,11 @@ protected virtual async Task OnPreviousHandlerAsync(MouseEventArgs e)
210214
if (!isCanceled)
211215
{
212216
Value = targetIndex;
213-
await ValueChanged.InvokeAsync(targetIndex);
217+
if (ValueChanged.HasDelegate)
218+
{
219+
await ValueChanged.InvokeAsync(targetIndex);
220+
}
221+
214222
StateHasChanged();
215223
}
216224
}
@@ -314,7 +322,11 @@ internal async Task ValidateAndGoToStepAsync(int targetIndex, bool validateEditC
314322
if (!isCanceled)
315323
{
316324
Value = targetIndex;
317-
await ValueChanged.InvokeAsync(targetIndex);
325+
if (ValueChanged.HasDelegate)
326+
{
327+
await ValueChanged.InvokeAsync(targetIndex);
328+
}
329+
318330
StateHasChanged();
319331
}
320332
}
@@ -329,7 +341,13 @@ internal int AddStep(FluentWizardStep step)
329341
SetCurrentStatusToStep(index);
330342
}
331343

332-
StateHasChanged();
344+
try
345+
{
346+
StateHasChanged();
347+
}
348+
catch (InvalidOperationException ex) when (ex.Message.Contains("render handle is not yet assigned", StringComparison.OrdinalIgnoreCase))
349+
{
350+
}
333351

334352
return index;
335353
}

src/Core/Components/Wizard/FluentWizardStep.razor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public FluentWizardStep(LibraryConfiguration configuration) : base(configuration
9393
/// For internal use only.
9494
/// </summary>
9595
[CascadingParameter]
96-
public FluentWizard FluentWizard { get; set; } = default!;
96+
internal FluentWizard FluentWizard { get; set; } = default!;
9797

9898
/// <summary>
9999
/// Gets or sets the summary of the step, to display near the label.

tests/Core/Components/Base/ComponentBaseTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public class ComponentBaseTests : Bunit.BunitContext
7070
{ typeof(FluentNavSectionHeader), Loader.Default.WithCascadingValue(new FluentNav(new LibraryConfiguration())) },
7171
{ typeof(FluentAppBarItem), Loader.Default.WithCascadingValue(new InternalAppBarContext(new FluentAppBar(new LibraryConfiguration()))) },
7272
{ typeof(FluentSortableList<>), Loader.MakeGenericType(typeof(string)).WithRequiredParameter("ItemTemplate", (RenderFragment<string>)(p => builder => builder.AddContent(0, "MyItemTemplate")))},
73+
{ typeof(FluentWizardStep), Loader.Default.WithCascadingValue(new FluentWizard(new LibraryConfiguration())) },
7374
};
7475

7576
/// <summary />

0 commit comments

Comments
 (0)