From e0f46df388b169b77a6e2e92b3f4c263b6329490 Mon Sep 17 00:00:00 2001 From: iGroza Date: Thu, 14 Mar 2024 14:32:12 +0700 Subject: [PATCH] fix: transaction address input --- src/components/transaction-address.tsx | 30 +++++++++++--------------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/src/components/transaction-address.tsx b/src/components/transaction-address.tsx index c3de36ec1..d6766750b 100644 --- a/src/components/transaction-address.tsx +++ b/src/components/transaction-address.tsx @@ -124,12 +124,6 @@ export const TransactionAddress = ({ [onAddress], ); - const onPressPaste = useCallback(async () => { - vibrate(HapticEffects.impactLight); - const pasteString = await SystemDialog.getClipboardString(); - setAddress(pasteString); - }, [setAddress]); - const myAccountsKeyExtractor = useCallback( (item: Wallet) => item.address, [], @@ -152,23 +146,23 @@ export const TransactionAddress = ({ const handleChangeAddress = useCallback( async (value: string) => { const nextValue = value.trim(); - // If nextValue longer than previous value more than 1 symbol that it is paste action - if (nextValue.length && nextValue.length > address.length + 1) { - await onPressPaste(); - } else if ( - // If nextValue increased by 1 or decreased by 1 than this is input action - nextValue.length === address.length + 1 || - nextValue.length + 1 === address.length - ) { + if (nextValue) { setAddress(nextValue); + setError(!AddressUtils.isValidAddress(nextValue)); + } else { + setAddress(''); + setError(false); } - - const isValidAddress = AddressUtils.isValidAddress(nextValue); - setError(!isValidAddress); }, - [onPressPaste, address], + [setAddress, setError, address], ); + const onPressPaste = useCallback(async () => { + vibrate(HapticEffects.impactLight); + const pasteString = await SystemDialog.getClipboardString(); + handleChangeAddress(pasteString); + }, [handleChangeAddress]); + return (