diff --git a/src/BootstrapBlazor/Components/EditorForm/EditorForm.razor b/src/BootstrapBlazor/Components/EditorForm/EditorForm.razor
index b5998b52ca8..870cb415ff3 100644
--- a/src/BootstrapBlazor/Components/EditorForm/EditorForm.razor
+++ b/src/BootstrapBlazor/Components/EditorForm/EditorForm.razor
@@ -3,42 +3,45 @@
@inherits BootstrapComponentBase
-
- @FieldItems?.Invoke(Model)
-
-
-
- @if (ShowUnsetGroupItemsOnTop)
- {
- if (UnsetGroupItems.Any())
+ @if (Model != null)
+ {
+
+ @FieldItems?.Invoke(Model)
+
+
+
+ @if (ShowUnsetGroupItemsOnTop)
{
- @RenderUnsetGroupItems
+ if (UnsetGroupItems.Any())
+ {
+ @RenderUnsetGroupItems
+ }
+ @foreach (var g in GroupItems)
+ {
+ @RenderGroupItems(g)
+ }
}
- @foreach (var g in GroupItems)
+ else
{
- @RenderGroupItems(g)
+ @foreach (var g in GroupItems)
+ {
+ @RenderGroupItems(g)
+ }
+ if (UnsetGroupItems.Any())
+ {
+ @RenderUnsetGroupItems
+ }
}
- }
- else
+
+
+ @if (Buttons != null)
{
- @foreach (var g in GroupItems)
- {
- @RenderGroupItems(g)
- }
- if (UnsetGroupItems.Any())
- {
- @RenderUnsetGroupItems
- }
+
}
-
-
- @if (Buttons != null)
- {
-
- }
-
+
+ }
@code
diff --git a/test/UnitTest/Components/EditorFormTest.cs b/test/UnitTest/Components/EditorFormTest.cs
index d62dd256453..5618645ba3f 100644
--- a/test/UnitTest/Components/EditorFormTest.cs
+++ b/test/UnitTest/Components/EditorFormTest.cs
@@ -51,13 +51,11 @@ public void CascadedEditContext_Ok()
[Fact]
public void Model_Error()
{
- Assert.ThrowsAny(() =>
+ var cut = Context.RenderComponent>(pb =>
{
- Context.RenderComponent>(pb =>
- {
- pb.Add(a => a.Model, null);
- });
+ pb.Add(a => a.Model, null);
});
+ Assert.Equal("", cut.Markup);
}
[Fact]