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: Correctly keep track of form field value updates when redoing an action #3789

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rumzledz
Copy link
Contributor

@rumzledz rumzledz commented Nov 27, 2024

Description

The issue was that, the defaultValues dependency was unstable. And so the hook in charge of initialising the form kept on resetting the form to use the default values. So even if Olga was setting the decision field to "Staking", under the hood, it kept on resetting back to "Decision". Fry doesn't have permissions in that scenario, hence the error banner.

This PR introduces a new hook called useStableDepsEffect which basically uses lodash's isEqual function to perform a comparison for the dependencies. So now, even if the defaultValues has a different reference on re-render, because its contents are identical each time, it won't cause the effect to run:

redo-ap

Testing

  1. Connect Leela's wallet
  2. Make sure that the Staking extension is enabled
  3. Assign Payer permissions to Fry in team Andromeda
  4. Create an Advanced Payment
  5. Connect Fry's wallet
  6. Go to the Dashboard
  7. Find the Advanced Payment action that was just made it and redo it
  8. Verify that you see this error banner:
image
  1. Change the Decision method to "Staking"
  2. Verify that the error goes away
  3. Fill in all other fields
  4. Verify that you are able to submit the form

Resolves #3777 #3703

@rumzledz rumzledz self-assigned this Nov 27, 2024
@rumzledz rumzledz force-pushed the fix/3777-properly-handle-object-deps branch from 03f3769 to d3c9955 Compare November 27, 2024 15:06
@rumzledz rumzledz marked this pull request as ready for review November 27, 2024 15:08
@rumzledz rumzledz requested a review from a team as a code owner November 27, 2024 15:08
@rumzledz rumzledz changed the title Fix: Correctly keep track of form field values when redoing an action Fix: Correctly keep track of form field value changes when redoing an action Nov 27, 2024
@rumzledz rumzledz changed the title Fix: Correctly keep track of form field value changes when redoing an action Fix: Correctly keep track of form field value updates when redoing an action Nov 27, 2024
Copy link
Contributor

@mmioana mmioana left a comment

Choose a reason for hiding this comment

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

Aaaand another one smashed @rumzledz 👏

Extension is enabled
Screenshot 2024-11-28 at 10 22 13

Gave fry payer permissions in Andromeda
Screenshot 2024-11-28 at 10 22 48

Created an Advanced payment with Permissions in General
Screenshot 2024-11-28 at 10 24 36

Redo action for fry shows up the error
Screenshot 2024-11-28 at 10 25 20

Selecting Staking
Screenshot 2024-11-28 at 10 25 26

And all good 👍
Screenshot 2024-11-28 at 10 25 44

Creating an Advanced payment in Andromeda as leela
Screenshot 2024-11-28 at 10 28 37

And fry can redo the action flawlessly ✨
Screenshot 2024-11-28 at 10 30 14

Niceeee job!

Copy link
Member

@rdig rdig left a comment

Choose a reason for hiding this comment

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

This works as described, you can now properly redo the action.

Screenshot from 2024-11-28 12-54-42
Screenshot from 2024-11-28 12-54-59
Screenshot from 2024-11-28 12-56-39
Screenshot from 2024-11-28 13-01-11
Screenshot from 2024-11-28 13-01-34
Screenshot from 2024-11-28 13-02-00

Copy link
Contributor

@Nortsova Nortsova left a comment

Choose a reason for hiding this comment

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

Fry redo error:
image

No errors for staking motion:
image

And successfully submitted staking motion 🎉
image

Great work 👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants