Skip to content

Commit 1be3eb3

Browse files
committed
Ensure labels aren't treated as values
The `TopicListViewComponent` includes support for a `DefaultLabel`. Previously, the `SelectListItem.Value` was set to `null`. This results in .NET (or, perhaps, HTML) using the label as the value, if no other value is selected. E.g., if the `TopicListAttribute`'s `DefaultValue` is set to "Select a topic…" and no topic is selected, then the value would be set to "Select a topic…". That's not what we want. By using an empty string instead, we mitigate this issue.
1 parent 18f676b commit 1be3eb3

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

OnTopic.Editor.AspNetCore/Components/TopicListViewComponent.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public IViewComponentResult Invoke(
7676
\-----------------------------------------------------------------------------------------------------------------------*/
7777
viewModel.TopicList.Add(
7878
new SelectListItem {
79-
Value = null,
79+
Value = "",
8080
Text = attribute.DefaultLabel
8181
}
8282
);

0 commit comments

Comments
 (0)