Fix issue where empty string in a dropdown is displayed as "empty".#72
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adjusts RawValueMapping so that an empty-string dropdown option no longer gets a generated raw value of "empty" (which can be shown in the UI), by allowing empty raw values and returning String.Empty when cleaning an empty display value.
Changes:
- Allow
TryGetByRawValueto accept empty strings by only treatingnullas “no raw value”. - Change
CleanDisplayValueto returnString.Emptyinstead of"empty"for null/empty display values.
Comments suppressed due to low confidence (1)
InteractiveAutomationToolkit/Components/RawValueMapping.cs:25
- There are component tests around raw-value cleaning/collisions (e.g., pipe-character cases), but no test coverage for the newly supported empty-string raw value path (empty option should map back correctly and not be rewritten to a placeholder). Add a unit test that exercises a DropDown (and ideally GenericDropDown) with an empty-string option, verifies Selected can be set to "", and verifies BlockDefinition.InitialValue/raw mapping behaves as intended.
public bool TryGetByRawValue(string rawValue, out T value)
{
if (rawValue == null)
{
value = default;
return false;
}
lock (lockObject)
{
return mapping.TryGetForward(rawValue, out value);
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| { | ||
| if (String.IsNullOrEmpty(displayValue)) | ||
| { | ||
| return "empty"; | ||
| return String.Empty; | ||
| } |
There was a problem hiding this comment.
Implemented in 2075af1. Empty/null display values now map to a non-empty raw value ("-") so selections can be serialized and parsed back correctly, and I added a focused test (DropDown_HandleEmptyOption) to cover the behavior.
Agent-Logs-Url: https://github.com/SkylineCommunications/Skyline.DataMiner.Utils.InteractiveAutomationScriptToolkit/sessions/c00753ce-0e3a-40f9-82b6-db3cb67707c9 Co-authored-by: ThomasRemmery <108457590+ThomasRemmery@users.noreply.github.com>
|
@copilot this does not fix the issue where if you pass an empty empty string is an option to a dropdown, it displays "empty" or "-" in your case. It should display an empty string. |
Agent-Logs-Url: https://github.com/SkylineCommunications/Skyline.DataMiner.Utils.InteractiveAutomationScriptToolkit/sessions/f6115893-0977-44d5-8786-398b162af642 Co-authored-by: ThomasRemmery <108457590+ThomasRemmery@users.noreply.github.com>
Adjusted in 84b3d6b. Empty/null dropdown display values now map to a visually blank raw sentinel ( |
No description provided.