From 3d438fc1e0f214979bb6a4e6f7af0627b525e3e4 Mon Sep 17 00:00:00 2001 From: Thijs Louisse Date: Tue, 26 Nov 2019 18:07:43 +0100 Subject: [PATCH] fix(input-amount): handle user pasting of amounts heuristically --- packages/field/src/FormatMixin.js | 6 +++++- packages/input-amount/src/LionInputAmount.js | 18 ++++++++++++++++++ packages/input-amount/stories/index.stories.js | 14 ++++++++++++-- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/packages/field/src/FormatMixin.js b/packages/field/src/FormatMixin.js index c59bb2fa9..b532d0102 100644 --- a/packages/field/src/FormatMixin.js +++ b/packages/field/src/FormatMixin.js @@ -310,12 +310,16 @@ export const FormatMixin = dedupeMixin( * `@user-input-changed` (this will happen later, when `formatOn` condition is met) */ _reflectBackFormattedValueToUser() { - if (!this.__isHandlingUserInput) { + if (this._reflectBackOn()) { // Text 'undefined' should not end up in this.value = typeof this.formattedValue !== 'undefined' ? this.formattedValue : ''; } } + _reflectBackOn() { + return !this.__isHandlingUserInput; + } + // This can be called whenever the view value should be updated. Dependent on component type // ("input" for or "change" for and it will become 4000 independent of your + locale.
+ If you write 4000,0 manually then it will become 4000 or 40000 dependent on your locale. +

`, );