-
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
templateLock={ false } breaks template in 5.2.1 #15965
Comments
Hi @mattjbrent, thank you for reporting this issue. Templates were implemented as a mechanism to prefill an InnerBlocks area with some pre-created blocks, in a similar way to what we had with CPT templates. In the last version of Gutenberg when there is a change in the number of columns the update to the InnerBlocks happens because the columns block dispatches an action to replace its InnerBlocks: In the previous version of the columns block before resizing functionality was added, when the number of columns changed the template was updated but the synchronization only happened because columns contains a templateLock all. So in order to fix the problem, you are facing I guess the best way is using a template lock all, so when the template changes a synchronization happens (you may then use child blocks inside without any locking), or you can explicitly call an action I hope you find this explanation clear if I missed something or you need additional information feel free to comment/reopen the issue so we can look further into this issue. |
@jorgefilipecosta thanks for your detailed reply. I solved this by also using replaceInnerBlocks and dealing with it more granularly. I'm also finding using the various exposed APIs reasonably sane to work with (although in some cases documentation is sparse and not particularly detailed) Are there more detailed documentation pertaining to more advanced APIs like this - I feel like the documentation on the site is very approachable but lacks depth and some of the inline documentation is not the clearest. If there was clearer documentation - i probably wouldnt have needed to ask this question. Thanks again for your time. |
Hi @mattjbrent I'm glad you managed to fix the problem. More advanced data api's are documented in https://developer.wordpress.org/block-editor/data/. The specific action is documented at replaceInnerBlocks https://developer.wordpress.org/block-editor/data/data-core-block-editor/#replaceInnerBlocks. |
Hmmm... this looks to be the reason why I'm working on an accordion-type block and found this behaviour to be completely unexpected and undocumented. I'm glad I finally noticed that (hopefully my rant helps inject a few more keywords to anyone trying to make an accordion, tab / tabs / tabbed, or similar type block ;) ) Thanks for submitting the bug @mattjbrent and MANY THANKS to @jorgefilipecosta for the detailed reply. Your valuable insights are hugely appreciated. Interestingly when investigating my issue, I looked over the coblocks accordion implementation, which does NOT set Thanks again! |
Describe the bug
A block was created similar to
core/columns
andcore/column
. Where the child block was set totemplateLock={ false }
and the parent block was set totemplateLock='all'
. It contained very similar functionality tocore/columns
. Moving a slider adds or removes a childcolumn
block.However changing the templateLock on the parent to false breaks the template when adding or removing new columns. Increasing the number of columns does not add in the additional blocks via the template.
To reproduce
Steps to reproduce the behavior:
core/column
andcore/columns
as a guide.templateLock
tofalse
on the column parent block in theedit
file.Expected behavior
Regardless of the templateLock setting, blocks added through templates should remain unchanged.
Screenshots
![Screen Shot 2019-06-03 at 9 11 55 AM](https://user-images.githubusercontent.com/18275831/58804451-e8b6b500-85df-11e9-90f7-923c81f32471.png)
The block hierarchy with
templateLock="all"
The same code, changing
![Screen Shot 2019-06-03 at 9 13 17 AM](https://user-images.githubusercontent.com/18275831/58804515-084ddd80-85e0-11e9-8e51-f09b9162d346.png)
templateLock={ false }
These are slightly modified but error is reproducible using fresh install of 5.2.1 and creating minimum viable block
Additional context
The text was updated successfully, but these errors were encountered: