Skip to content

fix: handle empty strings for Select component #18553

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 24, 2025

Conversation

jaaydenh
Copy link
Contributor

@jaaydenh jaaydenh commented Jun 24, 2025

resolve #18361

Its possible for a dynamic parameter option value to be an empty string which will cause the following error in the Radix Select component. The solution is to handle empty strings so that they are not set directly in the component.

Uncaught Error: A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.

data "coder_parameter" "radio" {
  name         = "radio"
  display_name = "An example of a radio input"
  description  = "The next parameter supports a single value."
  type         = "string"
  form_type    = "dropdown"
  order        = 1
  default      = ""

  option {
    name = "Empty"
    value = "" 
  }
}

@jaaydenh jaaydenh self-assigned this Jun 24, 2025
@jaaydenh jaaydenh requested a review from brettkolodny June 24, 2025 20:29
@jaaydenh jaaydenh merged commit 25f1b76 into main Jun 24, 2025
35 checks passed
@jaaydenh jaaydenh deleted the jaaydenh/select-empty-string-fix branch June 24, 2025 20:44
@github-actions github-actions bot locked and limited conversation to collaborators Jun 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Empty value for options in Dynamic parameters crashes the form
2 participants