Skip to content
This repository was archived by the owner on Aug 13, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "uiuiui",
"version": "0.5.17",
"version": "0.5.18",
"main": "dist/uiuiui.cjs.js",
"module": "dist/uiuiui.js",
"source": "src/index.js",
Expand Down
3 changes: 2 additions & 1 deletion src/Input/NumericInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ class NumericInput extends React.PureComponent {
}
}

// Don't format user input if it's not defined (so we don't end up with NaN)
format_user_input(value) {
return this.format_value(parseFloat(value));
return value ? this.format_value(parseFloat(value)) : value;
}

format_value(value, method = clamp) {
Expand Down
19 changes: 19 additions & 0 deletions src/Input/stories/index.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,25 @@ storiesOf('Input', module)
</Husk>
);
})
.add('NumericInput, Controller, Set to undefined', () => {
return (
<Husk useState={{ value: 50 }}>
{(state, setState) => (
<React.Fragment>
<NumericInput value={state.value} onChange={value => setState({ value })} />

<button
onClick={() => {
setState({ value: undefined });
}}
>
set to undefined
</button>
</React.Fragment>
)}
</Husk>
);
})
.add('ColorInput', () => {
return (
<ColorInput value="tomato" current={value => <Swatch color={value} />}>
Expand Down