Skip to content

Commit b204e84

Browse files
Fixed bug in Select component not allowing value == 0 (equinor#270)
* Fixed bug in `Select` component not allowing `value == 0` Co-authored-by: jorgenherje <jorgen.herje@ceetronsolutions.com>
1 parent 9f34083 commit b204e84

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [UNRELEASED] - YYYY-MM-DD
99

10+
### Fixed
11+
12+
- [#270](https://github.com/equinor/webviz-core-components/pull/270) - Fixed bug in `Select `component not allowing value to be `0`.
13+
1014
## [0.6.0] - 2022-10-03
1115

1216
### Fixed

react/src/lib/components/Select/Select.stories.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ const Template: ComponentStory<typeof Select> = (args) => {
4040
export const Basic = Template.bind({});
4141
Basic.args = {
4242
id: Select.defaultProps?.id || "select-component",
43-
size: Select.defaultProps?.size || 5,
43+
size: 6,
4444
options: [
45+
{ label: 0, value: 0 },
4546
{ label: 1, value: 1 },
4647
{ label: 2, value: 2 },
4748
{ label: 3, value: 3 },

react/src/lib/components/Select/Select.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -223,14 +223,14 @@ export const Select: React.FC<InferProps<typeof propTypes>> = (
223223
>
224224
<select
225225
value={
226-
selectedValues
227-
? typeof selectedValues === "string" ||
228-
typeof selectedValues === "number"
229-
? selectedValues
230-
: (selectedValues as (string | number)[]).map(
231-
(el) => el.toString()
232-
)
233-
: ""
226+
typeof selectedValues === "string" ||
227+
typeof selectedValues === "number"
228+
? multi
229+
? [selectedValues.toString()]
230+
: selectedValues
231+
: (selectedValues as (string | number)[]).map((el) =>
232+
el.toString()
233+
)
234234
}
235235
multiple={multi}
236236
size={size}

0 commit comments

Comments
 (0)