-
Notifications
You must be signed in to change notification settings - Fork 30
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
Add Deprecated Function for Existing Blocks #24
Comments
Am starting on |
Starting on |
@jomurgel and I worked at this for a good bit today. Right off the start, we ran into an issue where the If we changed out the I can verify that the attributes are getting changed when This could very well be a bug in the |
It would appear that we've run into an issue that doesn't appear to be documented anywhere. Perhaps something to open a ticket for on the Gutenberg repo. When the
The My best guess is that it has something to do with the fact that those elements are arrays instead of strings, but this is conjecture at best. Further digging is requred, but at this moment I'm marking the tasks as blocked until we can figure out a work around, fix, or Gutenberg issues an update. |
Spent several hours trying to figure out what was going on here, or find a solution. I did not. However, I did find that any component that returns an array to attributes fails if we're using the I don't think this is an ideal solution since we should be getting our https://github.com/humanmade/hm-gutenberg-tools/wiki/Editable-HTML Will continue to debug. |
@jomurgel and I did more digging on this issue yesterday. As a result, there are a few items I can confirm:
I feel like there is at the least a workaround we can come up with, it's just going to take more testing and digging in. |
Gutenberg Rendering IssueThe main issue here, or at least what has prompted this discussion, is that when a block is registered in Gutenberg a Now let's say you add this block to a page in the WP admin and save it. Later, you decide you want to change the markup of the block so you go and edit the The Initial FixAfter discussion on our weekly call, it was decided that Jo and I would go through each block and setup a Using this method would eliminate the need for a Something like this:
Fix One Bug, Find AnotherWhen using However, in the case of using a block like Better ExplanationHere is a better explanation of the issue by Andrew Duthie:
Main GH IssueThe main Github issue dealing with this can be found here: CommunityI did some research on GH and Slack and did find this exact issue being discussed in a few different places:
Other Noteable links
Thoughts / Moving ForwardIt seems that either choice, Is this as big of an issue as we think? Others like Delicious Brains think it is, so we are not alone. One idea that is worth exploring would be creating a Higher Order Component that takes the 'value/html' and converts it into string form so it can be passed to the |
Rendering Fix - Block VersioningIt does not seem that this topic is documented or even talked about too much. But it does look like there is a way to This is being implemented on core blocks, so I guess that makes it OK for us to do? Relevant Issues and PR's
The GistAlthough more discovery and testing needs to take place, here is how versioning works. Copy any existing Since the Here is a link to another example: Versioned Gutenberg Block · GitHub Questions / ThoughtsWhile looking into this issue, I got to thinking in regards to the
My first impression is that we should think about things like this. I personally think have no raw HTML in the edit or save functions could be a good pattern to follow? |
I was testing the First, start with your block just the way it is - beautiful and perfect. Add the deprecated function like so (using the WDS Default Block as an example):
Now, you can add new attributes and edit/save blocks if you need a new field. When you refresh the page in the dashboard, you'll get your updated block with new fields - and it doesn't break! However, you DO get this in the console:
The block actually still functions 100% and allows you to save values in your new field, and after you do so save & refresh the page, the console errors go away. So, the validation errors do not seem to affect the actual functionality and usage of the block, but I'm sure there's a way to get them to NOT show up. |
Committing to the same branch here rather than creating more confusion with more branches. Added the deprecated function in for the Default block. Added for the hero as well. I don't believe we need to worry about this for the Github Gist block as it's a dynamic render. I was able to successfully add a new attribute and input to the block and refresh the page in the dashboard without it breaking, so it appears that dynamic render blocks may not need to worry about Update: Confirmed in testing on the dummy Related Posts block I had in place that adding new inputs and attributes to a dynamic render block does not seem to require the use of Going to leave CTA and Two-Column for @efuller and @jomurgel respectively so they can play around with Thanks for all of the great info above y'all! |
Was the intention here just to add the deprecated property to all of our blocks (or the ones that break) whether they needed it or not? Please correct me if that was/is not the case. What do you think about only adding the deprecated property only when needed? This would help cut down on bundle size as well as the code in the actual block. In the meantime, I'm going to write up a bit of documentation on how to implement versioning. |
@efuller My thought was that it would be wise to add the |
I've added a page in the Wiki on block versioning! https://github.com/WebDevStudios/wds-gutenberg/wiki/Block-Versioning I think we can wrap this issue tomorrow morning! |
…DevStudios/wds-gutenberg into feature/#24-block-save-to-render-php
…ender-php Feature/#24 block save to render php
After learning that once a block is saved, you can't go back and update the markup (without breaking the block)
Please convert all the
save
methods from JSX to arender.php
file inside each respective block/component's directory.Setup a branch
feature/#24-block-save-to-render-php
for working.Edit: After some more digging by @efuller, we realized that there is a not-so-well documented
deprecated
function for rendering in JSX which allows you to add new fields, adjust the output, etc. without breaking the block on the backend. So that's nice! Updated the task name and directive here to add that in where we're able (i.e., blocks rendering via JSX and not PHP).The text was updated successfully, but these errors were encountered: