Skip to content

Commit 81beed1

Browse files
authored
fix(EditorForm): use GroupOrder group (#8030)
* refactor: 更改回使用 GroupOrder 分组 * chore: bump version 10.6.2-beta01 * test: 增加单元测试
1 parent dd38958 commit 81beed1

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

‎src/BootstrapBlazor/BootstrapBlazor.csproj‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
4-
<Version>10.6.1</Version>
4+
<Version>10.6.2-beta01</Version>
55
</PropertyGroup>
66

77
<ItemGroup>

‎src/BootstrapBlazor/Components/EditorForm/EditorForm.razor.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public partial class EditorForm<TModel> : IShowLabel, IDisposable
232232

233233
private IEnumerable<KeyValuePair<string, IOrderedEnumerable<IEditorItem>>> GroupItems => RenderItems
234234
.Where(i => !string.IsNullOrEmpty(i.GroupName) && i.IsVisible(ItemChangedType, IsSearch.Value))
235-
.GroupBy(i => i.GroupName).OrderBy(i => i.Key)
235+
.GroupBy(i => i.GroupOrder).OrderBy(i => i.Key)
236236
.Select(i => new KeyValuePair<string, IOrderedEnumerable<IEditorItem>>(i.First().GroupName!, i.OrderBy(x => x.Order)));
237237

238238
private List<IEditorItem>? _itemsCache;

‎test/UnitTest/Components/EditorFormTest.cs‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ public void GroupName_Order_Ok(bool showUnsetGroupItemsOnTop)
587587
builder.AddAttribute(index++, nameof(EditorItem<Foo, string>.Text), "Test-Text");
588588
builder.AddAttribute(index++, nameof(EditorItem<Foo, string>.Order), 1);
589589
builder.AddAttribute(index++, nameof(EditorItem<Foo, string>.GroupName), "Test-Group-1");
590-
builder.AddAttribute(index++, nameof(EditorItem<Foo, string>.GroupOrder), 1);
590+
builder.AddAttribute(index++, nameof(EditorItem<Foo, string>.GroupOrder), 2);
591591
builder.AddAttribute(index++, nameof(EditorItem<Foo, string>.EditTemplate), new RenderFragment<Foo>(foo => builder => builder.AddContent(0, "Test")));
592592
builder.CloseComponent();
593593

@@ -597,7 +597,7 @@ public void GroupName_Order_Ok(bool showUnsetGroupItemsOnTop)
597597
builder.AddAttribute(index++, nameof(EditorItem<Foo, string>.Text), "Test-Address");
598598
builder.AddAttribute(index++, nameof(EditorItem<Foo, string>.Order), 1);
599599
builder.AddAttribute(index++, nameof(EditorItem<Foo, string>.GroupName), "Test-Group-2");
600-
builder.AddAttribute(index++, nameof(EditorItem<Foo, string>.GroupOrder), 2);
600+
builder.AddAttribute(index++, nameof(EditorItem<Foo, string>.GroupOrder), 1);
601601
builder.CloseComponent();
602602

603603
builder.OpenComponent<EditorItem<Foo, bool>>(index++);
@@ -608,6 +608,11 @@ public void GroupName_Order_Ok(bool showUnsetGroupItemsOnTop)
608608
builder.CloseComponent();
609609
});
610610
});
611+
612+
var groups = cut.FindAll(".legend");
613+
Assert.Equal(2, groups.Count);
614+
Assert.Equal("Test-Group-2", groups[0].TextContent);
615+
Assert.Equal("Test-Group-1", groups[1].TextContent);
611616
}
612617

613618
private static RenderFragment<Foo> GenerateEditorItems(Foo foo) => f => builder =>

0 commit comments

Comments
 (0)