-
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
Block Bindings: Post metadata persists after connected block is removed #65683
Comments
@cbravobernal I made an issue for this persisting metadata issue you raised at WCUS. Was there anyone else in particular who mentioned this on your end? On my end, this was brought up to me by at least two other people at WCUS, who I've pinged for feedback on their use cases. It may be good to loop in additional folks to see how they're modeling content with bindings and how this issue shows up for them. |
Thanks for opening the issue. It'd be great to discuss what the expected behavior is. I see three main options: revert the changes made to post meta, set an empty value for the meta field, or keep the changes made (as it works right now). If I am not mistaken, other blocks like Post Title or Post Excerpt work the same way. You can insert a post excerpt, edit it, remove it, and the changes to post excerpt will prevail if you save the post. Whatever is decided I guess should apply to any of those scenarios. |
No one else reported to me, but it is true that is tricky. One problem for example is that more than one block in the same post can be bound to the same field. Screen.Recording.2024-09-26.at.18.53.18.movAlso, if you have a custom template with your layout using block bindings, there is not an easy way to edit their values without adding and removing paragraphs. As there is no option to edit the content inside the template, there is also no option to edit the values of the post meta data without adding a paragraph bound to it, and you may not need that paragraph. Screen.Recording.2024-09-26.at.19.13.32.mov |
revert the changes made to post metaThis seems the most secure option, but we will need to save the previous value somewhat and restore it on block deletion or block attribute reset. set an empty value for the meta fieldThis could break another blocks pointing to that field. Keep the changes made (as it works right now).This one causes confusion in the workflow. But also prevents error on different blocks with the same field bound to. |
There's a fourth option. We could show a popup and ask the user something along these lines: "This block has overridden a meta field. Would you like to reset it?" However, this may be too complicated and could introduce inconsistencies in the UX if we decide to allow connections to other default post meta in the future, such as title, publish date, etc.
Yeah I believe this discussion may have broader implications for the UX of content modeling with block bindings. The use case @cbravobernal surfaces in that video is one that I hadn't even considered before he showed it to me at WCUS. Here's a video reviewing what I thought was the primary use case while we were reviewing #64072. It has a clear way to modify the values: custom-post-types-trimmed.mp4It'd be great to hear on real-world use cases to get more information regarding how we could approach this, and what considerations to the UX may be in order. |
I’m not sure I understand the severity of the problem discussed. All scenarios covered work as expected. When you publish the post, all connected sources get their values stored on the server if configured similarly to the Post Meta source. The fact that the block with a connected source gets removed from the content should not impact the value of an external source. The same behavior could be observed when you change the binding source for the block. It also isn't different from how core blocks work like Post Title, Post Date, Post Featured Image, etc. For me it's a similar problem to what is tracked in these issues:
It's a recurring question whether to surface the detailed breakdown of all modified external sources when publishing a post similar to what exists in the site editor. If that would exist then it would be up to the user to decide what to do about the changes made through the connected Paragraph block that got removed afterwards. |
Description
When metadata is created via blocks bound to custom attributes, the metadata persists after the block is removed. This can result in unexpected behavior, such as that metadata continuing to erroneously render in a template.
This discussion also touches on overall Block Bindings UX, and may have implications for how we model content with bindings in the post editor, and potentially the site editor.
Step-by-step reproduction instructions
1. Register some custom post meta. For an easy example, here's code to register a custom post type with related meta:
Screenshots, screen recording, code snippet
removing-metadata.mp4
Environment info
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except Gutenberg.
The text was updated successfully, but these errors were encountered: