Skip to content
This repository was archived by the owner on Mar 8, 2023. It is now read-only.

Commit 355a03c

Browse files
authored
Merge pull request #76 from wysher/fix/number-input-0-value
fix(Inputs): input with type number not show 0 value
2 parents 3f33e9f + b7cc102 commit 355a03c

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

docs/stories/customComponents/Inputs.stories.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { useState } from 'react';
22
/* eslint-disable import/no-extraneous-dependencies */
33
import { storiesOf } from '@storybook/react';
44
import { Inputs } from '@buffetjs/custom';
5+
import { isUndefined } from 'lodash';
56

67
import Presentation from '../ui/Presentation';
78
import Pre from '../ui/Pre';
@@ -145,7 +146,11 @@ function InputStory() {
145146
name={input}
146147
{...form[input]}
147148
onChange={handleChange}
148-
value={state[input] || form[input].value}
149+
value={
150+
isUndefined(state[input])
151+
? form[input].value
152+
: state[input]
153+
}
149154
/>
150155
</div>
151156
))}

packages/buffetjs-custom/src/components/Inputs/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import React from 'react';
88
import PropTypes from 'prop-types';
9-
import { get, isEmpty, isFunction } from 'lodash';
9+
import { get, isEmpty, isFunction, isUndefined } from 'lodash';
1010
import {
1111
DatePicker,
1212
Checkbox,
@@ -64,6 +64,9 @@ function Inputs({
6464
case 'bool':
6565
inputValue = value || false;
6666
break;
67+
case 'number':
68+
inputValue = isUndefined(value) ? '' : value;
69+
break;
6770
default:
6871
inputValue = value || '';
6972
}

0 commit comments

Comments
 (0)