Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
aduth opened this issue Jun 20, 2018 · 0 comments
Closed
Assignees
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

Comments

@aduth
Copy link
Member

aduth commented Jun 20, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

1 participant