Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: revalidate recipient field on account change in the send flow #8621

Merged
merged 1 commit into from
Dec 13, 2024

Conversation

themooneer
Copy link
Contributor

@themooneer themooneer commented Dec 6, 2024

✅ Checklist

  • npx changeset was attached.
  • Covered by automatic tests.
  • Impact of the changes:
    • ...

📝 Description

  • When a user fill the recipient field and change account, the revalidation wasn't triggered. This PR will fix this issue.

See the following video

Before

before_revalidation.mov

Note: in the end of the video, i was forced to delete and re-paste the casper address so that it can be revalidated via the input onChange event.

After

after-revalidation.mov

Note: here the revalidation is controlled by both input onChange event and watching the account.id change from the selector above.

❓ Context

  • JIRA or GitHub link:

https://ledgerhq.atlassian.net/browse/LIVE-14904

🧐 Checklist for the PR Reviewers

  • The code aligns with the requirements described in the linked JIRA or GitHub issue.
  • The PR description clearly documents the changes made and explains any technical trade-offs or design decisions.
  • There are no undocumented trade-offs, technical debt, or maintainability issues.
  • The PR has been tested thoroughly, and any potential edge cases have been considered and handled.
  • Any new dependencies have been justified and documented.
  • Performance considerations have been taken into account. (changes have been profiled or benchmarked if necessary)

@themooneer themooneer requested a review from a team as a code owner December 6, 2024 05:52
Copy link

vercel bot commented Dec 6, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

4 Skipped Deployments
Name Status Preview Comments Updated (UTC)
ledger-live-github-bot ⬜️ Ignored (Inspect) Visit Preview Dec 13, 2024 6:23am
native-ui-storybook ⬜️ Ignored (Inspect) Visit Preview Dec 13, 2024 6:23am
react-ui-storybook ⬜️ Ignored (Inspect) Visit Preview Dec 13, 2024 6:23am
web-tools ⬜️ Ignored (Inspect) Visit Preview Dec 13, 2024 6:23am

@live-github-bot live-github-bot bot added the desktop Has changes in LLD label Dec 6, 2024
@@ -48,6 +48,21 @@ const RecipientField = <T extends Transaction, TS extends TransactionStatus>({
}
}, []); // eslint-disable-line react-hooks/exhaustive-deps

useEffect(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wdyt about combine both useEffect ? With something like that?

useEffect(() => {
    if (value !== "" && value !== transaction.recipient) {
      onChangeTransaction(bridge.updateTransaction(transaction, { recipient: value }));
      if (resetInitValue && initValue) {
        resetInitValue();
      }
    }
  }, [
    value,
    transaction.recipient,
    bridge,
    onChangeTransaction,
    transaction,
    initValue,
    resetInitValue,
    account.id,
  ]);

Copy link
Contributor Author

@themooneer themooneer Dec 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i did before, it didn't work (especially when you switch multiple time the same crypto accounts). if (resetInitValue && initValue) is not a valid condition to reset the initValue. Also the first effect will run one single time at the component mount. What i need is a second layer that manages the change of account.id basically. I would rather ignore exhaustive deps.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what you recommend as a refactor is a better abstraction, but with an uncontrolled resetInitiallValue, it gaves me a different behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
desktop Has changes in LLD
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants