Skip to content

Commit

Permalink
fix: revalidate recipient field on account change in the send flow (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
themooneer authored Dec 13, 2024
1 parent 1dd3a6d commit 9c06bd0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/witty-taxis-scream.md
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,21 @@ const RecipientField = <T extends Transaction, TS extends TransactionStatus>({
}
}, []); // 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 || {};
Expand Down

0 comments on commit 9c06bd0

Please sign in to comment.