-
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
Editor: Ignore save edit in undo history. #17452
Conversation
e6c2ee3
to
e8f75f7
Compare
packages/core-data/src/actions.js
Outdated
* | ||
* @return {Object} Action object. | ||
*/ | ||
export function* editEntityRecord( kind, name, recordId, edits ) { | ||
export function* editEntityRecord( kind, name, recordId, edits, undoIgnore ) { |
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.
Should we mark this argument as experimental? Also maybe an object is better in case we'd need more "options" in the future?
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.
I don't think it should be experimental, but it should be an object.
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.
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 and works well for me.
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.
I still have the issue on publish.
Added an e2e test for publishing. Would be great if this could be ignored the same way. |
I guess publishing is something that could be undone if it actually reverts the post to a draft. But not sure if that would be an expected user experience. |
@@ -155,7 +155,7 @@ export default compose( [ | |||
withDispatch( ( dispatch ) => { | |||
const { editPost, savePost } = dispatch( 'core/editor' ); | |||
return { | |||
onStatusChange: ( status ) => editPost( { status } ), | |||
onStatusChange: ( status ) => editPost( { status }, { undoIgnore: true } ), |
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.
I wonder if this is the right place to make this decision. Should status changes in general be ignored? Or publish status changes? Genuinely wondering...
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.
It depends on the context and the entity.
This will cover publishing status changes for posts and it makes sense to ignore that.
It will be very context-dependent which is why I didn't make it part of the entity configuration.
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.
Ok fair enough.
JS unit tests are failing |
Description
This PR fixes the leftover issue from #17259 (comment) by adding functionality to
core-data
that allows edits to opt out of being tracked in undo history and using that for the edit that persists the latest content right before saving.It also adds a test to guard for this regression.
How has this been tested?
The steps from #17259 (comment) no longer create an extra undo level.
Types of Changes
New Feature:
core-data
edits can now opt out of being tracked in history through an extra optional parameter,ignoreUndo
.Bug Fix: Extra undo levels are no longer created when saving the post.
Checklist: