Skip to content

Commit

Permalink
Block: fix html mode for non light blocks (#24335)
Browse files Browse the repository at this point in the history
* Block: fix html mode for non light blocks

* Flatten

* Fix inspector controls
  • Loading branch information
ellatrix committed Aug 4, 2020
1 parent 16b745a commit 80a04d8
Showing 1 changed file with 27 additions and 28 deletions.
55 changes: 27 additions & 28 deletions packages/block-editor/src/components/block-list/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,6 @@ function BlockListBlock( {
);
}

if ( mode !== 'visual' ) {
blockEdit = <div style={ { display: 'none' } }>{ blockEdit }</div>;
}

const value = {
clientId,
rootClientId,
Expand All @@ -219,33 +215,36 @@ function BlockListBlock( {
};
const memoizedValue = useMemo( () => value, Object.values( value ) );

let block;

if ( ! isValid ) {
block = (
<Block.div>
<BlockInvalidWarning clientId={ clientId } />
<div>{ getSaveElement( blockType, attributes ) }</div>
</Block.div>
);
} else if ( mode === 'html' ) {
// Render blockEdit so the inspector controls don't disappear.
// See #8969.
block = (
<>
<div style={ { display: 'none' } }>{ blockEdit }</div>
<Block.div __unstableIsHtml>
<BlockHtml clientId={ clientId } />
</Block.div>
</>
);
} else if ( lightBlockWrapper ) {
block = blockEdit;
} else {
block = <Block.div { ...wrapperProps }>{ blockEdit }</Block.div>;
}

return (
<BlockListBlockContext.Provider value={ memoizedValue }>
<BlockCrashBoundary onError={ onBlockError }>
{ isValid && lightBlockWrapper && (
<>
{ blockEdit }
{ mode === 'html' && (
<Block.div __unstableIsHtml>
<BlockHtml clientId={ clientId } />
</Block.div>
) }
</>
) }
{ isValid && ! lightBlockWrapper && (
<Block.div { ...wrapperProps }>
{ blockEdit }
{ mode === 'html' && (
<BlockHtml clientId={ clientId } />
) }
</Block.div>
) }
{ ! isValid && (
<Block.div>
<BlockInvalidWarning clientId={ clientId } />
<div>{ getSaveElement( blockType, attributes ) }</div>
</Block.div>
) }
{ block }
</BlockCrashBoundary>
{ !! hasError && (
<Block.div>
Expand Down

0 comments on commit 80a04d8

Please sign in to comment.