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

Block editor integration with state doesn't support undo and continues to save the old revision note on new revisions if not edited #9

Closed
helen opened this issue Feb 24, 2021 · 0 comments · Fixed by #10
Milestone

Comments

@helen
Copy link
Owner

helen commented Feb 24, 2021

This seems to be related to using state (possibly related: WordPress/gutenberg#18755), which is being done primarily to avoid the unsaved changes warning being shown when the user hasn't done anything except load the page, because the field value does need to be cleared out on load (and post-save) but if that's dispatched to meta immediately it's considered a "save". However, this does come with a bug, in that if you don't end up changing the revision note I believe it will still save the old one underneath.

I think there are two paths here, both of which start with getting rid of state and going back to dispatching the change to the editor data directly in onChange:

  1. Figure out how to ignore a given piece of data from whatever it is that tracks the "dirty"/edited state in the block editor, and dispatch to meta.
  2. Use register_rest_field() with an empty string for the get_callback and updating the post meta in update_callback, dispatching the change to said REST field. The existing routine will catch it for the revision. I believe @TimothyBJacobs mentioned something along these lines yesterday that I didn't quite fully grasp at the time, and @johnwatkins0 revived today.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant