From b62b14d97c6a74217f2c9bc0da5c47778b0aea41 Mon Sep 17 00:00:00 2001 From: Maxi Date: Mon, 17 Jun 2024 10:18:19 +0300 Subject: [PATCH] chore: remove trailing dot if no decimals are allowed in AmountInput --- src/components/AmountInput.vue | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/AmountInput.vue b/src/components/AmountInput.vue index 0c65f233a..8804ef634 100644 --- a/src/components/AmountInput.vue +++ b/src/components/AmountInput.vue @@ -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 ''; }