-
Notifications
You must be signed in to change notification settings - Fork 896
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
Conflict with ACF; last block added never renders #16600
Comments
(Sorry, accidentally @mentioned the wrong thread about ACF, which I've edited to fix). |
I can confirm this is happening, though like with the other issue; I can't easily find what causes this. Since it's functionality of ACF that is breaking here, I'd recommend posting these bugs to their issue trackers as well, as they might have an easier time determining what breaks here. And if it's something unconventional that the Yoast plugin does, we'd very much like to know so that we can look into it. However, it might as well be something that ACF needs to fix on their end. |
Have done some more debugging and it's definitely an issue on Yoast SEO's side. When ACF registers a block with registerBlockType, it uses a save function which adds the appropriate attributes to the code that should be in the editor. I added a console.log to this save function. I also added a console.log line to the core WP function serializeBlock. With Yoast SEO deactivated, this save function does not run immediately when I insert the block. Nothing outputs in the console until I interact with the page a bit further (eg clicking on a second block, switching to the code editor, or hitting publish). With Yoast SEO activated, it runs the instant I add the test block, and serializeBlock has empty attributes at that point (since the block has not called its save function). Something in Yoast SEO is resulting in block serialization occurring too early, and will affect not just ACF but any custom block with a custom save function. |
@smerriman - Great work debugging the issue so far 👍. @Djennez - Is it possible that YoastSEO is applying custom logic either via a JS filter or React Component that could cause a block to save at a different / early time? |
@elliotcondon as far as I was able to determine we don't. I also don't see any earlier save request in the requests to the server. I see the fetch block request happening, but |
As mentioned above, this isn't caused by requests to the server. Replace wp-includes/js/dist/blocks.min.js with the unminified version, and then add a logging statement to the serializeBlock function like I did above. You'll see exactly the same results as described - with Yoast deactivated, the logging call doesn't happen when the block is inserted (the editor is apparently set to some 'dirty' state, so serialization only happens later). With Yoast activated, it runs instantly, the editor gets the wrong content, and apparently isn't set to a dirty state so it doesn't update until you 'dirty' it in some other way (eg inserting a different block). |
@elliotcondon I think I may know what's going on here - while Yoast SEO is doing something that changes the timing of serialization, the "bug" may indeed be on ACF's side. I see that you are adding the block ID (which everything is based on) via the WordPress/gutenberg#7342 (comment)
So without Yoast SEO, this 'subtle unexpected behavior' never gets noticed, since it happens to trigger the update to the block ID as a side effect shortly afterwards. But whatever Yoast SEO is doing means the block is first serialized without the block ID, and now the unexpected behavior is severe, because the 'is dirty' state isn't triggering, so the block ID never gets added unless you make another change elsewhere in the editor. |
@smerriman Interesting... this could indeed be a part of the puzzle. From here, I'll need to perform some debugging work to isolate the issue. Under normal circumstances, I could give you an ETA, but we are quite busy right now with some upcoming projects and other bug fixes. Please leave this with me and I'll hope to have some answers shortly. |
Thanks. This wasn't happening late last year, so I'm guessing the change on Yoast's side was relatively recent - but since most sites use it, you'll probably start getting the bug reports streaming in (given it affects every single ACF block). For now the only way I can build sites is to disable Yoast SEO while creating everything in the editor. |
As an additional FYI, I'm having a similar issue with ACF, except in my case, all my ACF blocks do render both in the editor and on the page except ACF blocks that don't have any custom input fields, e.g., a code-only image separator. These non-input ACF blocks can be added to the editor, but don't appear on the page after saving. However, once any input block is added after the non-input block - either above or below, it doesn't matter - the non-input block appears. |
Please give us a description of what happened.
Previously I posted a major bug report where ACF default values were lost when Yoast SEO was active.
I haven't tested that recently, though now the situation appears to have gotten completely worse - the last ACF block you add to a page now appears to get entirely lost.
How can we reproduce this behavior?
<!-- wp:acf/testblock /-->
with all of the important details that ACF adds like block ID missing.
None of this happens when Yoast SEO is not installed.
Technical info
Used versions
The text was updated successfully, but these errors were encountered: