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

Allow flex justification controls to be disabled at the block level #67059

Merged
merged 3 commits into from
Nov 19, 2024
Merged
Changes from 2 commits
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
37 changes: 24 additions & 13 deletions packages/block-editor/src/layouts/flex.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,19 @@ export default {
onChange,
layoutBlockSupport = {},
} ) {
const { allowOrientation = true } = layoutBlockSupport;
const { allowOrientation = true, allowJustification = true } =
Copy link
Member

Choose a reason for hiding this comment

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

Just double checking the PR's description:

This PR updates the controls so they are only output when allowJustification is true.

Is it right that true is the default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it right that true is the default?

Yes!

layoutBlockSupport;
return (
<>
<Flex>
<FlexItem>
<FlexLayoutJustifyContentControl
layout={ layout }
onChange={ onChange }
/>
</FlexItem>
{ allowJustification && (
<FlexItem>
<FlexLayoutJustifyContentControl
layout={ layout }
onChange={ onChange }
/>
</FlexItem>
) }
<FlexItem>
{ allowOrientation && (
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we not render FlexItem if ! allowOrientation? It was from before, but we can update it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, updated!

<OrientationControl
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
Loading