Skip to content

Commit

Permalink
Fixed bug in Select component not allowing value == 0 (#270)
Browse files Browse the repository at this point in the history
* Fixed bug in `Select` component not allowing `value == 0`
Co-authored-by: jorgenherje <[email protected]>
  • Loading branch information
rubenthoms authored Oct 4, 2022
1 parent 9f34083 commit b204e84
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [UNRELEASED] - YYYY-MM-DD

### Fixed

- [#270](https://github.com/equinor/webviz-core-components/pull/270) - Fixed bug in `Select `component not allowing value to be `0`.

## [0.6.0] - 2022-10-03

### Fixed
Expand Down
3 changes: 2 additions & 1 deletion react/src/lib/components/Select/Select.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ const Template: ComponentStory<typeof Select> = (args) => {
export const Basic = Template.bind({});
Basic.args = {
id: Select.defaultProps?.id || "select-component",
size: Select.defaultProps?.size || 5,
size: 6,
options: [
{ label: 0, value: 0 },
{ label: 1, value: 1 },
{ label: 2, value: 2 },
{ label: 3, value: 3 },
Expand Down
16 changes: 8 additions & 8 deletions react/src/lib/components/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,14 @@ export const Select: React.FC<InferProps<typeof propTypes>> = (
>
<select
value={
selectedValues
? typeof selectedValues === "string" ||
typeof selectedValues === "number"
? selectedValues
: (selectedValues as (string | number)[]).map(
(el) => el.toString()
)
: ""
typeof selectedValues === "string" ||
typeof selectedValues === "number"
? multi
? [selectedValues.toString()]
: selectedValues
: (selectedValues as (string | number)[]).map((el) =>
el.toString()
)
}
multiple={multi}
size={size}
Expand Down

0 comments on commit b204e84

Please sign in to comment.