From e0b1cf3353bc7e1d5886ea85bd7a94775d1fe993 Mon Sep 17 00:00:00 2001 From: Pedro Figueiredo Date: Wed, 30 Oct 2024 17:46:19 +0000 Subject: [PATCH] fix: Prevent coercing symbols to zero in the edit spending cap modal --- app/_locales/en/messages.json | 3 +++ .../edit-spending-cap-modal.tsx | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index 61dce2e639a1..4ed3ddae1c93 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -1823,6 +1823,9 @@ "editSpendingCapError": { "message": "The spending cap can’t exceed $1 decimal digits. Remove decimal digits to continue." }, + "editSpendingCapSpecialCharError": { + "message": "Enter numbers only" + }, "enable": { "message": "Enable" }, diff --git a/ui/pages/confirmations/components/confirm/info/approve/edit-spending-cap-modal/edit-spending-cap-modal.tsx b/ui/pages/confirmations/components/confirm/info/approve/edit-spending-cap-modal/edit-spending-cap-modal.tsx index 2762e99652a5..f908333e4f25 100644 --- a/ui/pages/confirmations/components/confirm/info/approve/edit-spending-cap-modal/edit-spending-cap-modal.tsx +++ b/ui/pages/confirmations/components/confirm/info/approve/edit-spending-cap-modal/edit-spending-cap-modal.tsx @@ -124,6 +124,8 @@ export const EditSpendingCapModal = ({ decimals && parseInt(decimals, 10) < countDecimalDigits(customSpendingCapInputValue); + const showSpecialCharacterError = /[-+e]/u.test(customSpendingCapInputValue); + return ( )} + {showSpecialCharacterError && ( + + {t('editSpendingCapSpecialCharError')} + + )}