diff --git a/.changeset/witty-taxis-scream.md b/.changeset/witty-taxis-scream.md new file mode 100644 index 000000000000..8d18945b9949 --- /dev/null +++ b/.changeset/witty-taxis-scream.md @@ -0,0 +1,5 @@ +--- +"ledger-live-desktop": minor +--- + +recipient field on the send flow's revalidation process is controlled by both input onChange event and watching the account.id change from the selector above diff --git a/apps/ledger-live-desktop/src/renderer/modals/Send/fields/RecipientField.tsx b/apps/ledger-live-desktop/src/renderer/modals/Send/fields/RecipientField.tsx index 755466e39b88..f228a3d83160 100644 --- a/apps/ledger-live-desktop/src/renderer/modals/Send/fields/RecipientField.tsx +++ b/apps/ledger-live-desktop/src/renderer/modals/Send/fields/RecipientField.tsx @@ -48,6 +48,21 @@ const RecipientField = ({ } }, []); // eslint-disable-line react-hooks/exhaustive-deps + useEffect(() => { + // if the account changed, we should revalidate the recipient field + if (!initValue && value !== "" && value !== transaction.recipient) { + onChangeTransaction(bridge.updateTransaction(transaction, { recipient: value })); + } + }, [ + account.id, + value, + transaction.recipient, + bridge, + onChangeTransaction, + transaction, + initValue, + ]); + const onChange = useCallback( async (recipient: string, maybeExtra?: OnChangeExtra | null) => { const { currency } = maybeExtra || {};