From 0ed067af6a5d737beab1e9c98b03f18e512f3d5f Mon Sep 17 00:00:00 2001 From: Daniel Regeci Date: Sun, 6 May 2018 19:11:57 +0700 Subject: [PATCH] [FIX #4038] All symbols after dot/comma erased if editing decimal number in the transaction amount field --- src/status_im/ui/screens/wallet/request/views.cljs | 6 ++++-- src/status_im/ui/screens/wallet/send/views.cljs | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/status_im/ui/screens/wallet/request/views.cljs b/src/status_im/ui/screens/wallet/request/views.cljs index 1969aca4a8..6854b1f80f 100644 --- a/src/status_im/ui/screens/wallet/request/views.cljs +++ b/src/status_im/ui/screens/wallet/request/views.cljs @@ -28,7 +28,8 @@ ;; TODO(jeluard) both send and request flows should be merged (views/letsubs [{:keys [to to-name whisper-identity]} [:wallet.send/transaction] {:keys [amount amount-error]} [:wallet.request/transaction] - scroll (atom nil)] + scroll (atom nil) + amount-text-value (atom nil)] [comp/simple-screen {:avoid-keyboard? true} [comp/toolbar (i18n/label :t/new-request)] [react/view components.styles/flex @@ -45,7 +46,8 @@ :input-options {:default-value (str (money/to-fixed (money/wei->ether amount))) :max-length 21 :on-focus (fn [] (when @scroll (utils/set-timeout #(.scrollToEnd @scroll) 100))) - :on-change-text #(re-frame/dispatch [:wallet.request/set-and-validate-amount %])}}]]] + :on-change-text #(reset! amount-text-value %) + :on-end-editing #(re-frame/dispatch [:wallet.request/set-and-validate-amount @amount-text-value])}}]]] [bottom-buttons/bottom-buttons styles/bottom-buttons nil ;; Force a phantom button to ensure consistency with other transaction screens which define 2 buttons [button/button {:disabled? (not (and to amount)) diff --git a/src/status_im/ui/screens/wallet/send/views.cljs b/src/status_im/ui/screens/wallet/send/views.cljs index d2d2779a66..9589825bda 100644 --- a/src/status_im/ui/screens/wallet/send/views.cljs +++ b/src/status_im/ui/screens/wallet/send/views.cljs @@ -195,7 +195,8 @@ [advanced-cartouche transaction modal?])]) (defn- send-transaction-panel [{:keys [modal? transaction scroll advanced? symbol]}] - (let [{:keys [amount amount-error signing? to to-name sufficient-funds? in-progress? from-chat?]} transaction] + (let [{:keys [amount amount-error signing? to to-name sufficient-funds? in-progress? from-chat?]} transaction + amount-text-value (atom nil)] [wallet.components/simple-screen {:avoid-keyboard? (not modal?) :status-bar-type (if modal? :modal-wallet :wallet)} [toolbar from-chat? (if modal? act/close-white act/back-white) @@ -220,7 +221,8 @@ :input-options {:default-value (str (money/to-fixed (money/wei->ether amount))) :max-length 21 :on-focus (fn [] (when (and scroll @scroll) (utils/set-timeout #(.scrollToEnd @scroll) 100))) - :on-change-text #(re-frame/dispatch [:wallet.send/set-and-validate-amount %])}}] + :on-change-text #(reset! amount-text-value %) + :on-end-editing #(re-frame/dispatch [:wallet.send/set-and-validate-amount @amount-text-value])}}] [advanced-options advanced? transaction modal?]]] (if signing? [signing-buttons