From 5029b0d03ed89509a540169ad3574c4ecd468494 Mon Sep 17 00:00:00 2001 From: Tobias Bales Date: Sun, 6 Mar 2016 13:56:35 +0100 Subject: [PATCH] Fix label for number inputs with 0 as value For an the label would overlay the value when it was set to 0 (the integer) since the checking logic checked for javascript "trueishness". Now the check is explicit against null, undefined, empty string and NaN. --- components/input/Input.jsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/input/Input.jsx b/components/input/Input.jsx index 7e98ad96..46c18005 100644 --- a/components/input/Input.jsx +++ b/components/input/Input.jsx @@ -57,9 +57,11 @@ class Input extends React.Component { [style.withIcon]: icon }, this.props.className); + const valuePresent = value !== null && value !== undefined && value !== '' && !Number.isNaN(value); + const InputElement = React.createElement(multiline ? 'textarea' : 'input', { ...others, - className: ClassNames(style.input, {[style.filled]: value}), + className: ClassNames(style.input, {[style.filled]: valuePresent}), onChange: this.handleChange, ref: 'input', role: 'input',