Skip to content

Commit

Permalink
Blocks: Make sure Reusable Blocks get class name apllied properly
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed Dec 18, 2017
1 parent 6e6356a commit f2bcebb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion blocks/block-edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function BlockEdit( props ) {
// them preferencially as the render value for the block.
const Edit = blockType.edit || blockType.save;

return <Edit className={ className } { ...props } />;
return <Edit { ...props } className={ className } />;
}

export default withFilters( 'blocks.BlockEdit' )( BlockEdit );
10 changes: 7 additions & 3 deletions blocks/library/block/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import { __ } from '@wordpress/i18n';
/**
* Internal dependencies
*/
import { getBlockType, registerBlockType } from '../../api';
import BlockEdit from '../../block-edit';
import { registerBlockType } from '../../api';
import ReusableBlockEditPanel from './edit-panel';

class ReusableBlockEdit extends Component {
Expand Down Expand Up @@ -85,14 +86,13 @@ class ReusableBlockEdit extends Component {
}

const reusableBlockAttributes = { ...reusableBlock.attributes, ...attributes };
const blockType = getBlockType( reusableBlock.type );
const BlockEdit = blockType.edit || blockType.save;

return [
// We fake the block being read-only by wrapping it with an element that has pointer-events: none
<div key="edit" style={ { pointerEvents: isEditing ? 'auto' : 'none' } }>
<BlockEdit
{ ...this.props }
name={ reusableBlock.type }
focus={ isEditing ? focus : null }
attributes={ reusableBlockAttributes }
setAttributes={ isEditing ? this.setAttributes : noop }
Expand Down Expand Up @@ -160,6 +160,10 @@ registerBlockType( 'core/block', {
},
},

supports: {
customClassName: false,
},

edit: ConnectedReusableBlockEdit,
save: () => null,
} );

0 comments on commit f2bcebb

Please sign in to comment.