Automattic / jetpack

Security, performance, marketing, and design tools — Jetpack is made by WordPress experts to make WP sites safer and faster, and help you grow your traffic.
https://jetpack.com/
Other
1.59k stars 798 forks source link

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

Open coder-karen opened 6 months ago

coder-karen commented 6 months ago

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:

Demo:

https://github.com/Automattic/jetpack/assets/16754605/4a09e214-5a1f-4253-826f-8245aaff5755

Originally reported here: https://github.com/Automattic/jetpack/issues/35505#issuecomment-1932230242

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):

github-actions[bot] commented 2 weeks ago

This issue has been marked as stale. This happened because:

No further action is needed. But it's worth checking if this ticket has clear reproduction steps and it is still reproducible. Feel free to close this issue if you think it's not valid anymore — if you do, please add a brief explanation.