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.
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.
I don't think it should be experimental, but it should be an object.
youknowriad
left a comment
There was a problem hiding this comment.
Tested and works well for me.
ellatrix
left a comment
There was a problem hiding this comment.
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. |
| const { editPost, savePost } = dispatch( 'core/editor' ); | ||
| return { | ||
| onStatusChange: ( status ) => editPost( { status } ), | ||
| onStatusChange: ( status ) => editPost( { status }, { undoIgnore: true } ), |
There was a problem hiding this comment.
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.
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.
|
JS unit tests are failing |
Description
This PR fixes the leftover issue from #17259 (comment) by adding functionality to
core-datathat 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-dataedits 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: