close
Skip to content

Add method to clear edits to useEntityRecord return object #56399

@fabiankaegy

Description

@fabiankaegy

What problem does this address?

I'm trying to allow editors to edit data of a different post in a modal inside the editor of another post. In this case, we are talking about embedded products that get stored as their own post in a custom post type. To streamline the workflow for editors we are allowing them to make updates to the meta values of the product right inside the post they are working on.

However, we would like an editor to be able to cancel out of their edits and therefore reset any edits they have done on the external record.

This currently isn't really straightforward because when you try to pass the clean record to the edit method it fails because the type of the data for thinks like the title field isn't correct. The record has the title formatted as an object with rendered or raw as properties.

But the edit method expects the title to be a string value.

What is your proposed solution?

It would be great to get another method in the return object from the useEntityRecord hook which clears any customizations of the record and resets it to its original state.

Similar to how we already have edits and hasEdits it would be ideal to have another method called clearEdits to reset the state of the record.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions