Raised by @youknowriad at: #12331 (comment)
Currently, once a developer calls to editPost, there is no way for them to subsequently "unset" the edit, except by calling updatePost, which has a semantically distinct meaning in the sense of considering the value as the post's canonical saved value. A use case for unsetting an edit may not necessarily be in tandem with updating the post's saved value.
Consider then as an enhancement some option for unsetting an edit.
Some options include:
- Passing
undefined as a value for editPost should unset property
editPost( { someKey: undefined } );
- Passing the
currentPost (saved) value for editPost should unset property
editPost( { someKey: 'saved-value' } );
- A new action creator dedicated to unsetting edits
A solution should also account for the fact that some edited properties are "merged" (e.g. meta). A nested merged property could result in the removal of the top-level key if its unsetting would result in there being no other keys of the merged edit. For example, given edits: { meta: { a: 1 } }, calling editPost( { meta: { a: undefined } } ) should not only unset a, but also the top-level meta key.
My preference would be toward one or both of the first two options.
Raised by @youknowriad at: #12331 (comment)
Currently, once a developer calls to
editPost, there is no way for them to subsequently "unset" the edit, except by callingupdatePost, which has a semantically distinct meaning in the sense of considering the value as the post's canonical saved value. A use case for unsetting an edit may not necessarily be in tandem with updating the post's saved value.Consider then as an enhancement some option for unsetting an edit.
Some options include:
undefinedas a value foreditPostshould unset propertyeditPost( { someKey: undefined } );currentPost(saved) value foreditPostshould unset propertyeditPost( { someKey: 'saved-value' } );uneditPost( 'someKey' );A solution should also account for the fact that some edited properties are "merged" (e.g. meta). A nested merged property could result in the removal of the top-level key if its unsetting would result in there being no other keys of the merged edit. For example, given
edits: { meta: { a: 1 } }, callingeditPost( { meta: { a: undefined } } )should not only unseta, but also the top-levelmetakey.My preference would be toward one or both of the first two options.