Skip to content

Commit

Permalink
Allow flex justification controls to be disabled at the block level (#…
Browse files Browse the repository at this point in the history
…67059)

Co-authored-by: tellthemachines <[email protected]>
Co-authored-by: ramonjd <[email protected]>
Co-authored-by: ntsekouras <[email protected]>
  • Loading branch information
4 people authored Nov 19, 2024
1 parent 89cba32 commit 564f069
Showing 1 changed file with 28 additions and 17 deletions.
45 changes: 28 additions & 17 deletions packages/block-editor/src/layouts/flex.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,27 @@ export default {
onChange,
layoutBlockSupport = {},
} ) {
const { allowOrientation = true } = layoutBlockSupport;
const { allowOrientation = true, allowJustification = true } =
layoutBlockSupport;
return (
<>
<Flex>
<FlexItem>
<FlexLayoutJustifyContentControl
layout={ layout }
onChange={ onChange }
/>
</FlexItem>
<FlexItem>
{ allowOrientation && (
{ allowJustification && (
<FlexItem>
<FlexLayoutJustifyContentControl
layout={ layout }
onChange={ onChange }
/>
</FlexItem>
) }
{ allowOrientation && (
<FlexItem>
<OrientationControl
layout={ layout }
onChange={ onChange }
/>
) }
</FlexItem>
</FlexItem>
) }
</Flex>
<FlexWrapControl layout={ layout } onChange={ onChange } />
</>
Expand All @@ -94,14 +97,22 @@ export default {
onChange,
layoutBlockSupport,
} ) {
const { allowVerticalAlignment = true } = layoutBlockSupport;
const { allowVerticalAlignment = true, allowJustification = true } =
layoutBlockSupport;

if ( ! allowJustification && ! allowVerticalAlignment ) {
return null;
}

return (
<BlockControls group="block" __experimentalShareWithChildBlocks>
<FlexLayoutJustifyContentControl
layout={ layout }
onChange={ onChange }
isToolbar
/>
{ allowJustification && (
<FlexLayoutJustifyContentControl
layout={ layout }
onChange={ onChange }
isToolbar
/>
) }
{ allowVerticalAlignment && (
<FlexLayoutVerticalAlignmentControl
layout={ layout }
Expand Down

1 comment on commit 564f069

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 564f069.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/11903413820
📝 Reported issues:

Please sign in to comment.