Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/BootstrapBlazor.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<Version>10.3.1-beta03</Version>
<Version>10.3.1-beta04</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
15 changes: 15 additions & 0 deletions src/BootstrapBlazor/Components/Step/Step.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,21 @@ public async Task<int> Next()
return _currentStepIndex;
}

/// <summary>
/// <para lang="zh">设置当前步骤索引 <see cref="StepIndex"/> 值</para>
/// <para lang="en">Set current step index <see cref="StepIndex"/> value</para>
/// </summary>
/// <param name="index"></param>
public async Task SetStepIndex(int index)
{
_currentStepIndex = Math.Max(0, Math.Min(Items.Count, index));
if (IsFinished && OnFinishedCallback != null)
{
await OnFinishedCallback();
}
StateHasChanged();
}
Comment thread
ArgoZhang marked this conversation as resolved.
Comment thread
ArgoZhang marked this conversation as resolved.
Comment thread
ArgoZhang marked this conversation as resolved.

/// <summary>
/// <para lang="zh">重置步骤方法</para>
/// <para lang="en">Reset Step Method</para>
Expand Down
4 changes: 2 additions & 2 deletions src/BootstrapBlazor/Components/TreeView/TreeView.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,13 @@ public partial class TreeView<TItem> : IModelEqualityComparer<TItem>
public Func<TreeViewItem<TItem>, Task<IEnumerable<TreeViewItem<TItem>>>>? OnExpandNodeAsync { get; set; }

/// <summary>
/// <inheritdoc/>
/// <inheritdoc cref="IModelEqualityComparer{TItem}.CustomKeyAttribute"/>
/// </summary>
[Parameter]
public Type CustomKeyAttribute { get; set; } = typeof(KeyAttribute);

/// <summary>
/// <inheritdoc/>
/// <inheritdoc cref="IModelEqualityComparer{TItem}.ModelEqualityComparer"/>
Comment thread
ArgoZhang marked this conversation as resolved.
/// </summary>
[Parameter]
public Func<TItem, TItem, bool>? ModelEqualityComparer { get; set; }
Expand Down
27 changes: 24 additions & 3 deletions test/UnitTest/Components/StepTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public void Step_Method()
}

[Fact]
public void FinishedTemplate_Ok()
public async Task FinishedTemplate_Ok()
{
bool finished = false;
var cut = Context.Render<Step>(pb =>
Expand All @@ -143,8 +143,29 @@ public void FinishedTemplate_Ok()
});
});
var step = cut.Instance;
cut.InvokeAsync(() => step.Next());
cut.WaitForAssertion(() => cut.Contains("Finished-Template"));
await cut.InvokeAsync(() => step.Next());
cut.Contains("Finished-Template");
Assert.True(finished);
}

[Fact]
public async Task SetStepIndex()
{
bool finished = false;
var cut = Context.Render<Step>(pb =>
{
pb.Add(a => a.Items, GetStepItems);
pb.Add(a => a.StepIndex, 2);
pb.Add(a => a.OnFinishedCallback, () =>
{
finished = true;
return Task.CompletedTask;
});
});
var step = cut.Instance;
await cut.InvokeAsync(() => step.SetStepIndex(1));
Assert.False(finished);
await cut.InvokeAsync(() => step.SetStepIndex(3));
Assert.True(finished);
}

Expand Down