Skip to content

Commit

Permalink
Child Layout controls: Fix help text for height (WordPress#46319)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewserong authored and mpkelly committed Dec 7, 2022
1 parent 6800cd2 commit 5bbb779
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions packages/block-editor/src/hooks/child-layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@ import { useEffect } from '@wordpress/element';
*/
import useSetting from '../components/use-setting';

function helpText( selfStretch ) {
switch ( selfStretch ) {
case 'fill':
return __( 'Stretch to fill available space.' );
case 'fixed':
function helpText( selfStretch, parentLayout ) {
const { orientation = 'horizontal' } = parentLayout;

if ( selfStretch === 'fill' ) {
return __( 'Stretch to fill available space.' );
}
if ( selfStretch === 'fixed' ) {
if ( orientation === 'horizontal' ) {
return __( 'Specify a fixed width.' );
default:
return __( 'Fit contents.' );
}
return __( 'Specify a fixed height.' );
}
return __( 'Fit contents.' );
}

/**
Expand Down Expand Up @@ -64,7 +68,7 @@ export function ChildLayoutEdit( {
size={ '__unstable-large' }
label={ childLayoutOrientation( parentLayout ) }
value={ selfStretch || 'fit' }
help={ helpText( selfStretch ) }
help={ helpText( selfStretch, parentLayout ) }
onChange={ ( value ) => {
const newFlexSize = value !== 'fixed' ? null : flexSize;
setAttributes( {
Expand Down

0 comments on commit 5bbb779

Please sign in to comment.