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

Donations Block: Undo button will not remove the block #37185

Open
coder-karen opened this issue May 2, 2024 · 0 comments
Open

Donations Block: Undo button will not remove the block #37185

coder-karen opened this issue May 2, 2024 · 0 comments

Comments

@coder-karen
Copy link
Contributor

coder-karen commented May 2, 2024

What is the issue

On a self-hosted site using the Jetpack plugin, once a Donation block is added to a post or page it isn't possible to remove it with the undo button. With most other blocks, after adding the block and making none or a few changes, clicking the undo button will undo any changes and then remove the block (as a demo you can try with the Business Hours block).

To reproduce:

  • Create a new post or edit a template in the Site editor
  • Add the Donations block
  • Click undo
  • Verify the block is not removed

Demo:

Screen.Recording.2024-05-02.at.16.15.23.mov

Originally reported here: #35505 (comment)

Likely next steps

The issue is that we set the attributes for oneTimeDonation, monthlyDonation and annualDonation within a useEffect (see projects/plugins/jetpack/extensions/blocks/donations/tabs.js) which checks first to see if those values are set and that the planID matches the respective products value. The products value is set by doing a fetch request to WordPress.com (see projects/plugins/jetpack/extensions/blocks/donations/edit.js), and the oneTimeDonation, monthlyDonation and annualDonation attributes only set once that is received.

This happens on initial load, so clicking undo just repeats the fetch and setting of attributes.

Possible solutions (I've not looked into the feasibility of any of these):

  • fetching server side first for the initial attribute values.
  • do not save the oneTime, monthly and annual donations in attributes at all (perhaps we can always access the data dynamically...).
  • change the default display of the donations block (in the editor) until clicking a tab, so that the fetch request doesn't happen on the initial load.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant