Skip to content
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

fix(select-widget): select widget not able to select number value 0 #7254

Conversation

imangd
Copy link
Contributor

@imangd imangd commented Jul 17, 2024

Fixes #6515

Summary
When a select widget which has a value of 0 is selected, if isMultiple is set to false, null is selected and if isMultiple is set to true, an error is thrown. This happens because in optionToString function in SelectControl, the conditional checks for truthy value which excludes numerical 0 and returns null if a value of 0 is selected.

This PR proposes changes to this logic by explicitly checking the value type to be either number or string.
It also includes changes to the propTypes of SelectControl to match the types in schema.js.

Test plan

  1. Under dev-test/config.yml, replace options values ['a', 'b', 'c'] with [{ label: 'a', value: 0 }, { label: 'b', value: 1 }, { label: 'c', value: 2 }]
  2. Run dev-test locally: npm run start
  3. Go to Kitchen Sink and select option a for both select widgets

Checklist

Please add a x inside each checkbox:

A picture of a cute animal (not mandatory but encouraged)
image

@imangd imangd requested a review from a team as a code owner July 17, 2024 06:59
@martinjagodic martinjagodic enabled auto-merge (squash) August 1, 2024 12:10
@martinjagodic martinjagodic merged commit 804b3aa into decaporg:main Aug 1, 2024
9 checks passed
martinjagodic added a commit that referenced this pull request Aug 5, 2024
…#7254)

Fixes #6515

Co-authored-by: Martin Jagodic <jagodicmartin1@gmail.com>
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.

Select widget becomes empty when selecting an option with value 0
2 participants