Skip to content

Commit

Permalink
Fixed random collapse of the color settings section (#32388)
Browse files Browse the repository at this point in the history
  • Loading branch information
thisissandip authored and youknowriad committed Jun 7, 2021
1 parent 4bbea09 commit bbc0041
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions packages/block-editor/src/hooks/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,7 @@ export const withBlockControls = createHigherOrderComponent(
const withElementsStyles = createHigherOrderComponent(
( BlockListBlock ) => ( props ) => {
const elements = props.attributes.style?.elements;
if ( ! elements ) {
return <BlockListBlock { ...props } />;
}

const blockElementsContainerIdentifier = `wp-elements-${ useInstanceId(
BlockListBlock
) }`;
Expand All @@ -256,17 +254,23 @@ const withElementsStyles = createHigherOrderComponent(

return (
<>
<style
dangerouslySetInnerHTML={ {
__html: styles,
} }
/>
{ elements && (
<style
dangerouslySetInnerHTML={ {
__html: styles,
} }
/>
) }

<BlockListBlock
{ ...props }
className={ classnames(
props.classname,
blockElementsContainerIdentifier
) }
className={
elements &&
classnames(
props.classname,
blockElementsContainerIdentifier
)
}
/>
</>
);
Expand Down

0 comments on commit bbc0041

Please sign in to comment.