-
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
Page List: Render the children correctly in the editor #46165
Conversation
Co-authored-by: Andrei Draganescu <107534+draganescu@users.noreply.github.com>
Size Change: +75 B (0%) Total Size: 1.32 MB
ℹ️ View Unchanged
|
@talldan @youknowriad @Mamaduka pinging you in the context of you all having been involved in Mark applying block templates not persistent ( #45843 ): it seems we hit another problem with the way templates have been built to work. But this time it's not fixable, it's more of a question about what we want to do with block templates: it this a feature that should allow on the fly editing and applying via attribute and state changes, or is is something that is supposed to be synced once and then forgotten about? The question comes in the context of Pages List block implementing both inner blocks and the ability to filter the inner blocks via an attribute. We added inner blocks by making a block template b/c these inner blocks are not something editable, but automattic. But when we filter the blocks and reapply the template
Or is " |
@draganescu templates work hand in hand with "locking". If you want the template to keep being applied, I believe the locking should be "all" or something like that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is working well for me 👍
Does it still make sense to keep the changes introduced in #45843? |
* Page List: Render the children correctly in the editor Co-authored-by: Andrei Draganescu <107534+draganescu@users.noreply.github.com> * fix some leftovers from reimplementation (correcy deps and add memoization) Co-authored-by: Andrei Draganescu <107534+draganescu@users.noreply.github.com> Co-authored-by: Andrei Draganescu <andrei.draganescu@automattic.com>
Co-authored-by: Andrei Draganescu 107534+draganescu@users.noreply.github.com
What?
Alternative to #46122
This PR fixes a bug that appeared when merging #45861 and #45776 into trunk.
This has revealed that setting a template on inner blocks is not the right approach here. Instead we should use replaceBlocks, so avoid issues with template syncing.
Why?
To fix a bug where parent page selection is not reflected in the editor, but takes effect when the page list block is rendered.
Changes the implementation of the feature as well because fixing the bug in #46122 showed a problem with
synchronizeBlocksWithTemplate
where we always do synchronisation, but in this case we need to replace the blocks when the parent page attribute changes, irrespective of what the page list block already contains.This implementation while less elegant impacts less things than altering how
synchronizeBlocksWithTemplate
works.How?
Replaces the approach where we pass a template to inner blocks, and instead use createBlock and replaceBlock.
Testing instructions