Skip to content
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

Block: fix html mode for non light blocks #24335

Merged
merged 3 commits into from
Aug 4, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 28 additions & 24 deletions packages/block-editor/src/components/block-list/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,33 +219,37 @@ function BlockListBlock( {
};
const memoizedValue = useMemo( () => value, Object.values( value ) );

let block;

if ( isValid ) {
if ( mode === 'html' ) {
block = (
<Block.div __unstableIsHtml>
<BlockHtml clientId={ clientId } />
</Block.div>
);
} else if ( lightBlockWrapper ) {
block = blockEdit;
} else {
block = (
<Block.div { ...wrapperProps }>
{ blockEdit }
</Block.div>
);
}
} else {
block = (
<Block.div>
<BlockInvalidWarning clientId={ clientId } />
<div>{ getSaveElement( blockType, attributes ) }</div>
</Block.div>
);
}
ellatrix marked this conversation as resolved.
Show resolved Hide resolved

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