Skip to content

State: Refactor isEditedPostDirty to consider presence of edited properties #7409

@aduth

Description

@aduth

Related: #7130

Currently, the post editor prompts when unsaved changes exist based on the withChangeDetection higher-order reducer operating on state.editor, which includes both edits (fields like title, etc) and block manipulations. This has the downsides of: (a) needing to reset change detection when it's inferred to have been persisted (on save) and (b) manually considering the presence of edited fields after a save to re-trigger dirtiness (#7130 (comment)).

Instead, change detection is only needed on block details. The isEditedPostDirty should consider any fields in edits as being unsaved. This requires that "initial edits" (described in #7130 (comment)) be refactored as a separate state value, and that blocks state be reshaped to allow withChangeDetection to be applied to it specifically (via blocks.byUID and blocks.order by combineReducers). This itself has proven challenging to implement since combineReducers is not directly compatible with withChangeDetection, since the latter adds a property isDirty that causes warnings to occur by combineReducers expected shape.

Metadata

Metadata

Assignees

Labels

FrameworkIssues related to broader framework topics, especially as it relates to javascript[Type] TaskIssues or PRs that have been broken down into an individual action to take

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions