From 6c7f1e70d6ce850eec527a9719a98edbc00ad5aa Mon Sep 17 00:00:00 2001 From: Nikita Polyakov <53777036+Nikita-Polyakov@users.noreply.github.com> Date: Wed, 3 Mar 2021 14:48:50 +0300 Subject: [PATCH 1/2] add check inside blur handler (#151) --- package.json | 2 +- src/components/Input/SFloatInput.vue | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 07edcd64..b7ad64cb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@soramitsu/soramitsu-js-ui", - "version": "0.7.11", + "version": "0.7.12", "private": false, "publishConfig": { "registry": "https://nexus.iroha.tech/repository/npm-soramitsu-private/" diff --git a/src/components/Input/SFloatInput.vue b/src/components/Input/SFloatInput.vue index 28433217..5e159b4d 100644 --- a/src/components/Input/SFloatInput.vue +++ b/src/components/Input/SFloatInput.vue @@ -58,7 +58,9 @@ export default class SFloatInput extends Vue { ? DEFAULT_VALUE : this.trimNeedlessSymbols(this.value) - this.onInput(preparedValue) + if (preparedValue !== this.value) { + this.onInput(preparedValue) + } this.$emit('blur', event) } From 5a2822cd90c29d1338aaf3f88c306460cefef819 Mon Sep 17 00:00:00 2001 From: Nikita Polyakov <53777036+Nikita-Polyakov@users.noreply.github.com> Date: Thu, 4 Mar 2021 16:49:06 +0300 Subject: [PATCH 2/2] change formatNumberField method (#154) --- package.json | 2 +- src/components/Input/SFloatInput.vue | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index b7ad64cb..7398fd20 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@soramitsu/soramitsu-js-ui", - "version": "0.7.12", + "version": "0.7.13", "private": false, "publishConfig": { "registry": "https://nexus.iroha.tech/repository/npm-soramitsu-private/" diff --git a/src/components/Input/SFloatInput.vue b/src/components/Input/SFloatInput.vue index 5e159b4d..5badf370 100644 --- a/src/components/Input/SFloatInput.vue +++ b/src/components/Input/SFloatInput.vue @@ -69,7 +69,7 @@ export default class SFloatInput extends Vue { this.$emit('input', value) } - private trimNeedlessSymbols = (value: string): string => { + private trimNeedlessSymbols (value: string): string { // Trim zeros in the beginning if (value.indexOf('0') === 0 && value.indexOf('.') !== 1) { value = value.replace(/^0+/, '') @@ -86,10 +86,10 @@ export default class SFloatInput extends Vue { return value } - private formatNumberField = (value: string, decimals: number): string => { + private formatNumberField (value: string, decimals: number): string { if (!['string', 'number'].includes(typeof value)) return value - let formatted = String(value) + let formatted = String(value).replace(/[^\d.]/g, '') if (formatted.indexOf('.') === 0) { formatted = '0' + formatted @@ -104,7 +104,7 @@ export default class SFloatInput extends Vue { return formatted } - private valueMaxLength = (value: string, decimals: number) => { + private valueMaxLength (value: string, decimals: number) { if (value.length === 0 || decimals === undefined) return undefined const fpIndex = value.indexOf('.')