Skip to content

Editor: Consider option to unset edit from state #12334

@aduth

Description

@aduth

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
    • 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 } }, 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions