-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Site Editor: Fix broken 'Redo' by removing faulty logic for discarding unsaved Logo changes #37895
Conversation
This effect ran on unmount and used `getGlobalBlockCount` to determine if all Site Logo blocks have been removed, then discards any unsaved changes to the Logo and Icon. This does not work correctly in the Site Editor context, and would fire erroneously when switching between template parts, breaking the ability to 'Undo'/'Redo'.
Size Change: -77 B (0%) Total Size: 1.13 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for putting together this fix @stacimc! I had a little trouble replicating the issue at first (it seemed like the first time I do undo/redo it worked on trunk
but if I do undo/redo a second time after removing all site logo blocks, I could replicate it — or, if I edit outside of a template part I could replicate it more reliably).
Before: redo stops working
Kapture.2022-01-12.at.11.23.13.mp4
After: redo works reliably
Kapture.2022-01-12.at.11.27.58.mp4
This removal looks good to me to restore the redo behaviour in the site editor. 🤞 we can come up with another idea for how to preserve discarding changes when removing the last site logo, but that sounds like a lower priority task than getting this fix in. LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested well for me.
Would be nice to look for another solution for removing site logo block updates when all blocks are removed, but it makes sense to fix the regression by removing this code first
Opened #37900 to explore a different way to discard unsaved changes when removing the final Site Logo block. For now this should fix the regression. |
Backported to the minor. |
…37895) This effect ran on unmount and used `getGlobalBlockCount` to determine if all Site Logo blocks have been removed, then discards any unsaved changes to the Logo and Icon. This does not work correctly in the Site Editor context, and would fire erroneously when switching between template parts, breaking the ability to 'Undo'/'Redo'.
Fixes #37760
Description
#35892 introduced some changes to the Site Logo block, including an effect which was intended to discard any unsaved changes to the logo/icon if a user removes all their Site Logo blocks. This effect relied on
getGlobalBlockCount
to determine the existence of any Site Logo blocks, but does not work reliably in the Site Editor. If it fires erroneously, it breaks theRedo
button. (See testing instructions).This PR just removes that logic entirely in order to fix the Redo bug. Other options for discarding unsaved Site Logo changes can be explored separately at a much lower priority.
How has this been tested?
Verify you can reproduce the bug on trunk:
Now checkout this branch and repeat the testing instructions. This time, the "Redo" should be available and should re-insert the block removed by "Undo".
Screenshots
Types of changes
Checklist:
*.native.js
files for terms that need renaming or removal).