Skip to content

Commit

Permalink
fix(core/presentation): Fix controlled/uncontrolled warning for numbe…
Browse files Browse the repository at this point in the history
…r inputs (#7953)

this reverts #7881 and fixes it in the `orEmptyString` helper method

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
christopherthielen and mergify[bot] authored Feb 25, 2020
1 parent f0d0529 commit dde0456
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ export function NumberInput(props: INumberInputProps) {
useInternalValidator(validation, minMaxValidator);

const className = `NumberInput form-control ${orEmptyString(inputClassName)} ${validationClassName(validation)}`;
return <input className={className} type="number" value={value} {...otherProps} />;
return <input className={className} type="number" value={orEmptyString(value)} {...otherProps} />;
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import classNames from 'classnames';
import { isString } from 'lodash';
import { isString, isNil } from 'lodash';

import { noop } from 'core/utils';

import { IFormInputValidation } from './interface';

export const orEmptyString = (val: any) => val || '';
export const orEmptyString = (val: any) => (isNil(val) ? '' : val);

export const validationClassName = (validation = {} as IFormInputValidation) => {
return classNames({
Expand Down

0 comments on commit dde0456

Please sign in to comment.