Commit af5e765
committed
Ensured that optional topic list doesn't break editor
In a recent update (753d0a4), the `TopicListViewComponent` was updated to not render to the interface if there were no items to render in the list—or, rather, if the only item was the default placeholder label with an empty value. In those cases, it doesn't make sense to cluter the interface with an empty dropdown menu.
Unfortunately, this broke OnTopic. Because this was being removed as part of a loop over ` GetAttributeDescriptors()`, it introduced a gap in the naming convention used for the `name` attribute (e.g., `Attributes[0]`, `Attributes[2]`…). And the default model binding in MVC will stop looking for subsequent fields in a collection if it encounters a gap. As such, any attributes placed after an empty `TopicListViewComponent` also wouldn't be displayed. Oops!
This fixed that by rendering the necessary fields as `<hidden />` inputs, thus allowing the attribute to be hidden from the interface, while still providing ASP.NET Core the information it needs to maintain correct model binding.
In this case, the `TopicListViewComponent` will still get `POST`ed to the server, but as whatever its existing value is, which is what we want. That way, it won't get overwritten if, for some reason, it's set to a value.1 parent acecc86 commit af5e765
1 file changed
Lines changed: 5 additions & 0 deletions
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
18 | 23 | | |
0 commit comments