Blocks: Move logic for generating class name to BlockEdit component#4009
Blocks: Move logic for generating class name to BlockEdit component#4009
Conversation
179905a to
83dfe66
Compare
youknowriad
left a comment
There was a problem hiding this comment.
It looks like this introduced a regression in Reusable blocks. To test save a pullquote as a reusable block, and reload, it'll lose its styles.
Good catch @youknowriad. you opened a can of worms, see #3967 (comment) :) |
83dfe66 to
f2bcebb
Compare
| }, | ||
| }, | ||
|
|
||
| supports: { |
There was a problem hiding this comment.
Let implementing block decide whether the custom class name is supported.
| * Internal dependencies | ||
| */ | ||
| import { getBlockType, registerBlockType, hasBlockSupport, getBlockDefaultClassname } from '../../api'; | ||
| import BlockEdit from '../../block-edit'; |
There was a problem hiding this comment.
👍
Is this exposed? How do we use this component when moved to the editor module :)
There was a problem hiding this comment.
Yes, it is exposed: https://github.com/WordPress/gutenberg/blob/master/blocks/index.js#L21.
| attributes: block.attributes, | ||
| className, | ||
| } ), | ||
| getSaveElement( blockType, block.attributes ), |
There was a problem hiding this comment.
Won't we have a React warning here about the missing key?
|
@youknowriad it is ready for another look. |
youknowriad
left a comment
There was a problem hiding this comment.
LGTM 👍 Nice refactoring

Description
Raised in #3741 (comment):
When working on this I discovered that preview for invalid EditBlock doesn't get updated with all
supportsoptions likeanchorin case of heading. This PR fixes it.This was always the case for Reusable Block. This PR fixes it by sharing the same logic within
<BlockEdit />component.How Has This Been Tested?
Manually and unit tests.
Test steps:
<x>at the end.<x>@noisysocks, can you double check it works properly with Reusable blocks?
Checklist: