hasChangedContent: remove obsolete blocks check#45090
Merged
Merged
Conversation
|
|
|
Size Change: -7 B (0%) Total Size: 1.27 MB
ℹ️ View Unchanged
|
Contributor
|
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
Member
Author
Me too 🙂 |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
hasChangedContentselector would returntrueeven when the post doesn't have any non-transient edits, only the transientblocksedit. Thisblocksedit is added on editor initialization, namely onEntityProvidermount, and merely calculates the parsed blocks from the post's originalcontent.We only need to check
'content' in editsbecause every relevantblocksedit will add acontentedit, too, setting it to a function that serializes the blocks when called.The
'blocks' in editscheck was originally added in #10844 at a time when blocks state was in theeditorstore, and it was checking the blocks' dirty flag:state.editor.present.blocks.isDirty. Then thiseditorblocks state was refactored tocoreentities 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
hasChangedContentwhich 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:
isEditedPostAutosaveableselector and watch what it returnsisEditedPostAutosaveable. Verify that it returnsfalsenow.The selector used to return
trueeven on unchanged post.