-
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
Blocks: Move logic for generating class name to BlockEdit component #4009
Conversation
179905a
to
83dfe66
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -167,6 +160,10 @@ registerBlockType( 'core/block', { | |||
}, | |||
}, | |||
|
|||
supports: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let implementing block decide whether the custom class name is supported.
@@ -15,7 +14,8 @@ import { __ } from '@wordpress/i18n'; | |||
/** | |||
* Internal dependencies | |||
*/ | |||
import { getBlockType, registerBlockType, hasBlockSupport, getBlockDefaultClassname } from '../../api'; | |||
import BlockEdit from '../../block-edit'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Is this exposed? How do we use this component when moved to the editor
module :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't we have a React warning here about the missing key?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed with 3650811.
@youknowriad it is ready for another look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
supports
options likeanchor
in 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: