Skip to content

Commit

Permalink
fix(number-inputs): prevent emitting 0 when empty
Browse files Browse the repository at this point in the history
  • Loading branch information
leomp12 committed May 9, 2020
1 parent 403f6f7 commit e54d6c0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/components/_inputs/js/InputMoney.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ export default {
get () {
return this.value
},
set (value) {
this.$emit('input', Number(value))
set (val) {
const num = parseFloat(val)
this.$emit('input', isNaN(num) ? null : num)
}
},

Expand All @@ -50,7 +51,7 @@ export default {
},

mounted () {
if (this.schema.default) {
if (typeof this.schema.default === 'number') {
this.localValue = this.schema.default
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/_inputs/js/InputNumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default {
},

mounted () {
if (this.schema.default) {
if (typeof this.schema.default === 'number') {
this.localValue = this.schema.default
}
}
Expand Down

0 comments on commit e54d6c0

Please # to comment.