Skip to content

Commit

Permalink
chore: remove trailing dot if no decimals are allowed in AmountInput
Browse files Browse the repository at this point in the history
  • Loading branch information
onmax committed Jun 17, 2024
1 parent 7b0900b commit b62b14d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/components/AmountInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,18 @@ const AmountInput = defineComponent({
// regExpResult[1] contains the sign
// regExpResult[2] contains the whole integers
// regExpResult[3] contains the decimal point and decimals
return [
let formattedValue = [
props.preserveSign ? (regExpResult[1] || '+') : '',
regExpResult[2] || (regExpResult[3] ? '0' : ''),
regExpResult[3] || '',
].join('');
// Remove trailing dot if no decimals are allowed
if (props.decimals === 0) {
formattedValue = formattedValue.replace(/\.$/, '');
}
return formattedValue;
}
return '';
}
Expand Down

0 comments on commit b62b14d

Please sign in to comment.