-
Notifications
You must be signed in to change notification settings - Fork 2k
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
FSE: Append new blocks inside post content block #34425
Conversation
This PR does not affect the size of JS and CSS bundles shipped to the user's browser. Generated by performance advisor bot at iscalypsofastyet.com. |
Seems to be a core bug caused by having a parent block with a locked template and a nested block with an unlocked template: WordPress/gutenberg#11681 Will try to manually override the template validity by dispatching a |
Fixed in 0443021 |
Nice work figuring out a solution to this! I ran through all the suggested testing steps quickly and it works as specified for me so far, but will do some more rigorous testing in the morning. |
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.
Great work @mmtr! This PR nails multiple rough edges with interactions that were previously possible. Went though the testing instructions and everything worked as expected.
I was suspecting that we'll have to handle the case of "inline" inserters (the +
one that appear between blocks) separately:
It looks like we got that for free with template locking, while still preserving it inside of content slot. ✨
On top of that the template blocks can't be moved around anymore.
apps/full-site-editing/full-site-editing-plugin/full-site-editing/class-full-site-editing.php
Show resolved
Hide resolved
Dang, I found an error in further testing. Everything works fine with existing pages, but when I try to add a new page I'm running into the blank screen with the following error:
|
Dismissing the approval to make sure we investigate the Uncaught TypeError: Cannot read property 'insertBefore' of null
error before merging
.../full-site-editing/full-site-editing-plugin/full-site-editing/editor/block-inserter/index.js
Outdated
Show resolved
Hide resolved
...diting/full-site-editing-plugin/full-site-editing/editor/template-validity-override/index.js
Show resolved
Hide resolved
.../full-site-editing/full-site-editing-plugin/full-site-editing/editor/block-inserter/index.js
Outdated
Show resolved
Hide resolved
...l-site-editing-plugin/full-site-editing/editor/block-inserter/post-content-block-appender.js
Show resolved
Hide resolved
Excellent work @mmtr!! |
a1e8aed
to
d9ca5b8
Compare
Thanks for the update @mmtr! Not sure if it's just me, but when testing locally I'm still running into an error when trying to create a new page, although a different one this time (likely not related with this PR but it gets in the way of testing):
I logged this one here #34481 along with the PR that might have introduced it. I also noticed that the inserter now appears before the back button, not sure if that was the case previously: But that can be handled in follow-up PRs as long as we log an issue to keep track of it. |
d9ca5b8
to
775655c
Compare
Created another follow up issue to track incorrect inserter button position here: #34544 |
Changes proposed in this Pull Request
This PR replaces the block inserter in the header toolbar with a custom one that ensures that new blocks are appended inside the post content block.
Since the default inserter in the header toolbar rendered by Gutenberg doesn't set any
rootClientId
(#), we cannot define which block should contain any new inserted block.This PR aims to solve that by rendering a replica of the same header inserter but using the client id of the post content block as
rootClientId
. The same client id is also used now when inserting a starter page template to avoid that content being appended after the footer (#34330).In order to don't display the default header inserter, we lock the template making impossible to insert new blocks in the root (thus the header doesn't show the default block inserter). But this also prevents the user from removing existing blocks, which solves the issue of having the post content block removable (#34331).
Testing instructions
/wp-admin/edit.php?post_type=wp_template
).Fixes #34327.
Fixes #34330.
Fixes #34331.