-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
hasChangedContent: remove obsolete blocks check #45090
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jsnajdr
added
[Feature] Saving
Related to saving functionality
[Package] Editor
/packages/editor
labels
Oct 19, 2022
Open in CodeSandbox Web Editor | VS Code | VS Code Insiders |
Size Change: -7 B (0%) Total Size: 1.27 MB
ℹ️ View Unchanged
|
The change looks good but subtle changes like that worry me a bit :P. Let's see how it goes. |
youknowriad
approved these changes
Oct 20, 2022
Me too 🙂 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes a bug where the
hasChangedContent
selector would returntrue
even when the post doesn't have any non-transient edits, only the transientblocks
edit. Thisblocks
edit is added on editor initialization, namely onEntityProvider
mount, and merely calculates the parsed blocks from the post's originalcontent
.We only need to check
'content' in edits
because every relevantblocks
edit will add acontent
edit, too, setting it to a function that serializes the blocks when called.The
'blocks' in edits
check was originally added in #10844 at a time when blocks state was in theeditor
store, and it was checking the blocks' dirty flag:state.editor.present.blocks.isDirty
. Then thiseditor
blocks state was refactored tocore
entities in #16932, and changed this condition to just'blocks' in edits
. But this condition is not needed nowadays.The PR also removes obsolete unit tests for
hasChangedContent
which were working with the old state shape (likestate.editor.present.blocks
) and mockinggetEntityRecordEdits
. Such tests are very far from real-world usage.How to test:
Look at the original report (#27950 (comment)) and verify this workflow:
isEditedPostAutosaveable
selector and watch what it returnsisEditedPostAutosaveable
. Verify that it returnsfalse
now.The selector used to return
true
even on unchanged post.