diff --git a/packages/block-editor/src/components/justify-content-control/ui.js b/packages/block-editor/src/components/justify-content-control/ui.js index 08c13079c2fcc9..60848db7405187 100644 --- a/packages/block-editor/src/components/justify-content-control/ui.js +++ b/packages/block-editor/src/components/justify-content-control/ui.js @@ -7,6 +7,7 @@ import { justifyCenter, justifyRight, justifySpaceBetween, + justifyStretch, } from '@wordpress/icons'; import { __ } from '@wordpress/i18n'; @@ -15,6 +16,7 @@ const icons = { center: justifyCenter, right: justifyRight, 'space-between': justifySpaceBetween, + stretch: justifyStretch, }; function JustifyContentUI( { @@ -66,6 +68,13 @@ function JustifyContentUI( { isActive: 'space-between' === value, onClick: () => handleClick( 'space-between' ), }, + { + name: 'stretch', + icon: justifyStretch, + title: __( 'Stretch items' ), + isActive: 'stretch' === value, + onClick: () => handleClick( 'stretch' ), + }, ]; const UIComponent = isToolbar ? ToolbarGroup : ToolbarDropdownMenu; diff --git a/packages/block-editor/src/layouts/flex.js b/packages/block-editor/src/layouts/flex.js index bd200ec7b961aa..64ff11475a6707 100644 --- a/packages/block-editor/src/layouts/flex.js +++ b/packages/block-editor/src/layouts/flex.js @@ -314,7 +314,6 @@ function FlexLayoutJustifyContentControl( { label: __( 'Space between items' ), } ); } else { - // Todo: we also need an icon here. justificationOptions.push( { value: 'stretch', icon: justifyStretch, @@ -360,18 +359,42 @@ function FlexWrapControl( { layout, onChange } ) { } function OrientationControl( { layout, onChange } ) { - const { orientation = 'horizontal' } = layout; + const { + orientation = 'horizontal', + verticalAlignment, + justifyContent, + } = layout; return ( - onChange( { + onChange={ ( value ) => { + // Make sure the vertical alignment and justification are compatible with the new orientation. + let newVerticalAlignment = verticalAlignment; + let newJustification = justifyContent; + if ( value === 'horizontal' ) { + if ( verticalAlignment === 'space-between' ) { + newVerticalAlignment = 'center'; + } + if ( justifyContent === 'stretch' ) { + newJustification = 'left'; + } + } else { + if ( verticalAlignment === 'stretch' ) { + newVerticalAlignment = 'top'; + } + if ( justifyContent === 'space-between' ) { + newJustification = 'left'; + } + } + return onChange( { ...layout, orientation: value, - } ) - } + verticalAlignment: newVerticalAlignment, + justifyContent: newJustification, + } ); + } } >