Skip to content

Fix issue where empty string in a dropdown is displayed as "empty".#72

Merged
ThomasRemmery merged 3 commits into
10.6.3.Xfrom
EmptyDropDownOption
May 20, 2026
Merged

Fix issue where empty string in a dropdown is displayed as "empty".#72
ThomasRemmery merged 3 commits into
10.6.3.Xfrom
EmptyDropDownOption

Conversation

@ThomasRemmery
Copy link
Copy Markdown
Collaborator

No description provided.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 TryGetByRawValue to accept empty strings by only treating null as “no raw value”.
  • Change CleanDisplayValue to return String.Empty instead 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.

Comment on lines 118 to 122
{
if (String.IsNullOrEmpty(displayValue))
{
return "empty";
return String.Empty;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@ThomasRemmery
Copy link
Copy Markdown
Collaborator Author

@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.

Copy link
Copy Markdown
Contributor

Copilot AI commented May 20, 2026

@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.

Adjusted in 84b3d6b. Empty/null dropdown display values now map to a visually blank raw sentinel ("\u200B"), so the option stays visually empty instead of showing empty or -, while preserving round-trip behavior. Screenshot: N/A (library-only change; no UI asset in this repo).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants