diff --git a/lib/block-supports/layout.php b/lib/block-supports/layout.php
index 1af4a7f842c4d..2ea8871df102e 100644
--- a/lib/block-supports/layout.php
+++ b/lib/block-supports/layout.php
@@ -76,6 +76,11 @@ function gutenberg_get_layout_style( $selector, $layout, $has_block_gap_support
'space-between' => 'space-between',
);
+ $flex_wrap_options = array( 'wrap', 'nowrap' );
+ $flex_wrap = ! empty( $layout['flexWrap'] ) && in_array( $layout['flexWrap'], $flex_wrap_options, true ) ?
+ $layout['flexWrap'] :
+ 'wrap';
+
$style = "$selector {";
$style .= 'display: flex;';
if ( $has_block_gap_support ) {
@@ -83,7 +88,7 @@ function gutenberg_get_layout_style( $selector, $layout, $has_block_gap_support
} else {
$style .= 'gap: 0.5em;';
}
- $style .= 'flex-wrap: wrap;';
+ $style .= "flex-wrap: $flex_wrap;";
$style .= 'align-items: center;';
/**
* Add this style only if is not empty for backwards compatibility,
diff --git a/packages/block-editor/src/hooks/layout.scss b/packages/block-editor/src/hooks/layout.scss
index 9d154045c5a28..653f9da7b9bda 100644
--- a/packages/block-editor/src/hooks/layout.scss
+++ b/packages/block-editor/src/hooks/layout.scss
@@ -23,6 +23,7 @@
}
.block-editor-hooks__flex-layout-justification-controls {
+ margin-bottom: $grid-unit-15;
legend {
margin-bottom: $grid-unit-10;
}
diff --git a/packages/block-editor/src/layouts/flex.js b/packages/block-editor/src/layouts/flex.js
index fd8e446aa2ae0..03ed93d31a266 100644
--- a/packages/block-editor/src/layouts/flex.js
+++ b/packages/block-editor/src/layouts/flex.js
@@ -8,7 +8,7 @@ import {
justifyRight,
justifySpaceBetween,
} from '@wordpress/icons';
-import { Button } from '@wordpress/components';
+import { Button, ToggleControl } from '@wordpress/components';
/**
* Internal dependencies
@@ -24,6 +24,8 @@ const justifyContentMap = {
'space-between': 'space-between',
};
+const flexWrapOptions = [ 'wrap', 'nowrap' ];
+
export default {
name: 'flex',
label: __( 'Flex' ),
@@ -32,10 +34,13 @@ export default {
onChange,
} ) {
return (
-
+ <>
+
+
+ >
);
},
toolBarControls: function FlexLayoutToolbarControls( {
@@ -60,7 +65,11 @@ export default {
const blockGapSupport = useSetting( 'spacing.blockGap' );
const hasBlockGapStylesSupport = blockGapSupport !== null;
const justifyContent =
- justifyContentMap[ layout.justifyContent ] || 'flex-start';
+ justifyContentMap[ layout.justifyContent ] ||
+ justifyContentMap.left;
+ const flexWrap = flexWrapOptions.includes( layout.flexWrap )
+ ? layout.flexWrap
+ : 'wrap';
return (