Simplify the RESET_BLOCK action to fix template part focus mode content loss#37283
Merged
youknowriad merged 1 commit intotrunkfrom Dec 13, 2021
Merged
Simplify the RESET_BLOCK action to fix template part focus mode content loss#37283youknowriad merged 1 commit intotrunkfrom
youknowriad merged 1 commit intotrunkfrom
Conversation
youknowriad
commented
Dec 10, 2021
| @@ -637,70 +594,17 @@ const withInnerBlocksRemoveCascade = ( reducer ) => ( state, action ) => { | |||
| */ | |||
| const withBlockReset = ( reducer ) => ( state, action ) => { | |||
Contributor
Author
There was a problem hiding this comment.
We can probably now remove these HoR and just move its logic to the sub reducers.
|
Size Change: -151 B (0%) Total Size: 1.11 MB
ℹ️ View Unchanged
|
Mamaduka
approved these changes
Dec 10, 2021
Member
Mamaduka
left a comment
There was a problem hiding this comment.
Thanks again, Riad.
This fix works as expected.
ntsekouras
reviewed
Dec 10, 2021
Contributor
Unrelated, but do you know why we did that? |
Contributor
Author
yes, we didn't have any "core" store, and it was just the initial naive implementation of reusable blocks. It went through several iterations since. |
noisysocks
pushed a commit
that referenced
this pull request
Dec 14, 2021
Member
|
@youknowriad It looks like we have slight regression after this PR - #37361. |
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.
closes #36937
A long time ago, we used to keep the reusable blocks parsed content inside the "block-editor" store even if these were not rendered. To be able to do so, we needed to keep the blocks of these reusable blocks in state when
RESET_BLOCKSaction was called as it only concerns the "main" block list.That behavior though is a bit problematic now when we switch to template part focus mode because when we do so, a block that was "controlled" become top-level in the store so "uncontrolled", and when we come back to the old state, the "controlled" block was kept in the state but not its children, so it seemed like the content disappeared because
getBlock( id )of these child blocks was returningnull.This PR removes that old RESET_BLOCKS` behavior because I believe it's probably useless nowadays and potentially a source for memory leaks. I'm not certain yet that I didn't miss any hidden use case for that behavior but let's see what e2e tests say.