gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Custom css classes for dynamic blocks are not saved

Open cristian-raiber opened this issue 8 years ago • 1 comments

Describe the bug When you add a custom class to a dynamic block (archives, latest comments etc) and update the post, the custom class gets saved and displayed on the front-end like it should. But the next time you reload the editor, the custom class is no longer there (Additional CSS Class field is empty). This means that if you update the post again, the custom classes that you previously added, will be deleted and no longer ouputted on the front-end.

To Reproduce Steps to reproduce the behavior: u

Expected behavior The custom class that we previously added, should be displayed in Additional CSS Class textfield.

Potential fix This only happens to dynamic blocks, so I think the issue is with the addParsedDifference filter.
https://github.com/WordPress/gutenberg/blob/c28d2dbe2e5a01cdb30cfa884170c76e8b548fd6/packages/editor/src/hooks/custom-class-name.js#L134-L154 Because dynamic blocks don't have a save render implementation, this filter will delete the classname from the block attributes. Maybe modify this filter to be applied only to non-dynamic blocks.

Similar issues #9929, #9423.

cristian-raiber avatar Sep 18 '18 08:09 cristian-raiber

i experienced the same issue trying to add a custom class onto the legacy menu block in the widget: inserting the custom class, saving the page; reloading the page; no class is displayed in the admin nor in the page issue partially fixed? :/ :(

jrgd avatar Sep 04 '25 19:09 jrgd