-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Styles variations don't work for blocks using InnerBlocks
#9897
Comments
This issue raises something interesting: It's impossible to "preview" a block (Use One potential solution is to change how Thoughts @aduth and others? |
@youknowriad Would your idea also fall along the same lines of thinking of having an |
Just to get a clearer sense of this, is it accurate to say that blocks with |
That's true. I think we can provide a less than ideal fix for now until the root issue (which requires a big refactoring) is addressed. What we can do right now, is to use an error boundary around the preview component as it should possible to use the style variation without the need to preview it. |
InnerBlocks
Tested with the latest version of the Gutenberg 4.5.1, but the problem still persists. |
Same here. Tested and problem still exists. Thanks! |
@youknowriad @aduth Are there any fixes available for this issue yet? With 5.0 already available we need to have this issue fixed in order to release our plugin. Do you have function that we can use to check if it's on preview? Like |
@phpbits There were no updates to this issue here, so no news. The error boundary suggestion is something that would need to be added in Gutenberg itself, I think. |
I'd really love to see a fix for this. Adding styles to blocks with If there is anything I can do to get my hands dirty and help address this, please let me know--I'd love to help out. |
Is the problem just with the little previews that display in the Inspector? Those make a lot of sense for things like buttons, but not-so-much for large blocks. Maybe the simplest solution would just be to have an option to disable/customize the previews in the style selector, as opposed to refactoring InnerBlocks. for instance:
I would be fine with just having a fallback vanilla radio input or dropdown… after all the user will see the effects in the editor anyway. |
I'd be fine with an error boundary and we fallback to "no-preview" when there's an error. If anyone has bandwidth for this, go for it. |
+1 for adding no-preview. I'm currently using |
@phpbits Can you elaborate on that fix? I don't get where/what you are doing to bypass the error. |
@kraftner It's seems that |
Error when clicking on Style Panel.
https://github.com/WordPress/gutenberg/blob/v4.7.1/packages/editor/src/components/inner-blocks/index.js#L41 |
@SpencerCloud Yes, it's just a conditional check in |
@SpencerCloud Did you just wrap the |
Right. Here's an example of some code in an edit function that I used:
There may be a better way to do it, but that's what worked for me. |
Great, thanks @SpencerCloud ! |
Wanted to comment and ask if this is being looked at? It seems like a pretty significant bug. I'd love to have options for styling my container blocks without having to rely on people pasting in classnames |
This is still happening as of today with WordPress 5.1.1. |
If anyone wants to disable Preview Style in var el = wp.element.createElement;
var allowColumnStyle = wp.compose.createHigherOrderComponent( function( BlockEdit ) {
return function( props ) {
var content = el( BlockEdit, props );
if( props.name === 'core/columns' && typeof props.insertBlocksAfter === 'undefined' ) {
content = el( 'div', {} );
}
return el(
wp.element.Fragment, {}, content
);
};
}, 'allowColumnStyle' );
wp.hooks.addFilter( 'editor.BlockEdit', 'my/gutenberg', allowColumnStyle ); Put it in the same JS file where you call Basically whenever we want to show a Preview (either in Main Editor or Styles), it triggers When creating preview for Styles, |
I think this is even more important with the introduction of the Group bloc. |
+1, just encountered it with the Group block and with the Description List block. Currently I have to manually set the class of block (Advanced tab, Additional CSS Class, |
Squeaky wheel gets the grease adding another comment. |
This error, exactly as described by @macemmek, just reared its head again. I'm running 5.2.2, fresh install, and trying to register a style for the core/cover block (I can also reproduce it with a self-made blocktype that uses InnerBlocks). When I click on styles the editor crashes, yielding the following message in the console:
Times the amount of styles registered. I've got a couple of sites that use styles like this, and I think this might be a regression somewhere. |
@mevanloon It's fixed in the plugin but it's not shipped yet in WordPress Core. |
@youknowriad What is the usual timeframe between fixes to the plugin and implementation in WP Core? |
That depends on the timeframe of the major Core releases. Core doesn't follow a strict schedule. Here's the planning for the next one. https://make.wordpress.org/core/2019/08/07/wordpress-5-3-planning-roundup/ |
Thanks @youknowriad, glad to know I'm not going mad. I'll just wait for the proper release then. |
I'm experiencing the same problem when adding a block style to the core/cover block via |
Unfortunately I've experienced the same error while registering Block Styles for Here is how it's done
The error code
|
Was there ever a resolve here? I get the issue when trying to register a block style for media-text |
Describe the bug
I'd like to create a custom section block with additional style variants. The section is going to be a wrapper for multiple blocks - so parent block with some inner blocks.
Unfortunately, an attempt of choosing styles triggers an error Cannot read property 'innerBlocks' of null
Maybe there's a bug or maybe I'm doing wrong.
To Reproduce
Create the block:
The copied error is like below:
Expected behavior
Style variants to choose should appear without an error.
Additional context
The text was updated successfully, but these errors were encountered: