State: Refactor isEditedPostDirty to consider presence of edited properties #7409
Labels
Framework
Issues related to broader framework topics, especially as it relates to javascript
[Type] Task
Issues or PRs that have been broken down into an individual action to take
Related: #7130
Currently, the post editor prompts when unsaved changes exist based on the
withChangeDetection
higher-order reducer operating onstate.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 inedits
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 allowwithChangeDetection
to be applied to it specifically (viablocks.byUID
andblocks.order
bycombineReducers
). This itself has proven challenging to implement sincecombineReducers
is not directly compatible withwithChangeDetection
, since the latter adds a propertyisDirty
that causes warnings to occur bycombineReducers
expected shape.The text was updated successfully, but these errors were encountered: