Gutenberg: Attributes adding by addFilter not be saved on custom blocks (core blocks still saved)

Created on 23 Apr 2018  路  7Comments  路  Source: WordPress/gutenberg

test-extra-blocks.zip

Issue Overview


As the title, the attributes adding by using addFilter() not saved on blocks which is manually added by third party plugins, its still be saved on core blocks. I have attached my sample plugin to use for testing and producing the issue.

Steps to Reproduce (for bugs)


  1. Install attached plugins (it contains a custom blocks and an script to add extra attributes)
  2. Create post/page, add an any core block and any custom block (Here is the Spacer block installed by plugin attached)
  3. Input text to Extra options on Inspector controls on both core block and custom block.
  4. Save the post/page.
  5. Reload the post/page. The extra attributes on custom blocks is gone and we will receive a validation error on that block.

Expected Behavior



The extra attributes should be saved on custom blocks also, as it is on core blocks.

Needs Technical Feedback [Feature] Blocks [Feature] Extensibility [Status] Needs More Info [Type] Bug

All 7 comments

I tested test-extra-blocks.zip with WordPress 4.9.7 and Gutenberg 3.3.0 and found that I was unable to add the spacer block from that plugin without seeing an error so I cannot get to step 3. (30s)

@JoomUnited since it has been about 3 months since this issue was opened, and there has been a lot of development happening in that time, would it be possible to get an updated example plugin for testing?

Hi @designsimply ,
Sorry for late response.
I have updated the code for test block (check my attachment).
Hope you can find the solutions for this.
Thanks in advance.

test-extra-blocks.zip

@designsimply @JoomUnited can you please tell me how can we save value of the text field for third party blocks, as in "blocks.registerBlockType" filter we can set custom attributes to core blocks only

Updating wordpress beta 5.0 with latest gutenberg plugin version solves the issue

@JoomUnited apologies for the extended delay in reply. I tried installing https://github.com/WordPress/gutenberg/files/2231058/test-extra-blocks.zip by activating the plugin on WordPress 5.0.3 with no other active plugins and it results in the editor showing a blank screen and the following console error: "TypeError: can't convert undefined to object" for extra.js.

Because Gutenberg has now been merged into WordPress and because you are asking for help creating custom code, may I ask that you refresh the example code again if you are still working on it? I will subscribe to this issue and watch for a reply more closely.

Aside: I also noticed there is a new issue at https://github.com/WordPress/gutenberg/issues/13413 which discusses filters I'm adding the link in case it's helpful for you.

@designsimply WP update fixed the issue.
I close the issue.

Hooray! 馃帀

And thank you for the follow-up @JoomUnited. It is appreciated. 馃檪

Was this page helpful?
0 / 5 - 0 ratings