Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 04c67fa

Browse files
committed
avoid 0 display confusing
1 parent 5f417d3 commit 04c67fa

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/react-numeral-input.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,10 @@ const NumeralInput = React.createClass({
9090
};
9191
},
9292
getNumeralValue: function(val) {
93-
return numeral(val).format(this.props.fmt);
93+
if (val) {
94+
return numeral(val).format(this.props.fmt);
95+
}
96+
return '';
9497
},
9598
componentWillReceiveProps: function(nextProps) {
9699
if( this.props.value === nextProps.value){
@@ -102,7 +105,7 @@ const NumeralInput = React.createClass({
102105
if (!reg.test(val)) {
103106
formatVal = this.getNumeralValue(val);
104107
}
105-
formatVal = this.getNumeralValue(val);
108+
// formatVal = this.getNumeralValue(val);
106109

107110
this.setState( {
108111
value: formatVal
@@ -136,7 +139,7 @@ const NumeralInput = React.createClass({
136139
//parentNode onChange function
137140
this.setState( {
138141
pos: pos,
139-
value: val
142+
value: val || ''
140143
}, () => {
141144
if (this.props.onChange) {
142145
this.props.onChange(val);

0 commit comments

Comments
 (0)