Skip to content

Commit

Permalink
revert: default height to 100px if left unset (#69450)
Browse files Browse the repository at this point in the history
Co-authored-by: yogeshbhutkar <[email protected]>
Co-authored-by: t-hamano <[email protected]>
  • Loading branch information
3 people authored Mar 6, 2025
1 parent 55de75c commit 997934d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 21 deletions.
1 change: 0 additions & 1 deletion packages/block-library/src/spacer/constants.js
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export const MIN_SPACER_SIZE = 0;
export const DEFAULT_HEIGHT = '100px';
8 changes: 4 additions & 4 deletions packages/block-library/src/spacer/controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { View } from '@wordpress/primitives';
* Internal dependencies
*/
import { unlock } from '../lock-unlock';
import { DEFAULT_HEIGHT, MIN_SPACER_SIZE } from './constants';
import { MIN_SPACER_SIZE } from './constants';
import { useToolsPanelDropdownMenuProps } from '../utils/hooks';

const { useSpacingSizes } = unlock( blockEditorPrivateApis );
Expand Down Expand Up @@ -100,7 +100,7 @@ export default function SpacerControls( {
resetAll={ () => {
setAttributes( {
width: undefined,
height: DEFAULT_HEIGHT,
height: '100px',
} );
} }
dropdownMenuProps={ dropdownMenuProps }
Expand Down Expand Up @@ -128,9 +128,9 @@ export default function SpacerControls( {
<ToolsPanelItem
label={ __( 'Height' ) }
isShownByDefault
hasValue={ () => height !== DEFAULT_HEIGHT }
hasValue={ () => height !== '100px' }
onDeselect={ () =>
setAttributes( { height: DEFAULT_HEIGHT } )
setAttributes( { height: '100px' } )
}
>
<DimensionInput
Expand Down
14 changes: 5 additions & 9 deletions packages/block-library/src/spacer/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { useSelect, useDispatch } from '@wordpress/data';
*/
import { unlock } from '../lock-unlock';
import SpacerControls from './controls';
import { DEFAULT_HEIGHT, MIN_SPACER_SIZE } from './constants';
import { MIN_SPACER_SIZE } from './constants';

const { useSpacingSizes } = unlock( blockEditorPrivateApis );

Expand Down Expand Up @@ -169,13 +169,9 @@ const SpacerEdit = ( {

const getHeightForVerticalBlocks = () => {
if ( isFlexLayout ) {
return DEFAULT_HEIGHT;
return undefined;
}
return (
temporaryHeight ||
getSpacingPresetCssVar( height ) ||
DEFAULT_HEIGHT
);
return temporaryHeight || getSpacingPresetCssVar( height ) || undefined;
};

const getWidthForHorizontalBlocks = () => {
Expand Down Expand Up @@ -283,7 +279,7 @@ const SpacerEdit = ( {
const newSize =
getCustomValueFromPreset( width, spacingSizes ) ||
getCustomValueFromPreset( height, spacingSizes ) ||
DEFAULT_HEIGHT;
'100px';
setAttributesCovertly( {
width: '0px',
style: {
Expand All @@ -299,7 +295,7 @@ const SpacerEdit = ( {
const newSize =
getCustomValueFromPreset( height, spacingSizes ) ||
getCustomValueFromPreset( width, spacingSizes ) ||
DEFAULT_HEIGHT;
'100px';
setAttributesCovertly( {
height: '0px',
style: {
Expand Down
8 changes: 1 addition & 7 deletions packages/block-library/src/spacer/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
*/
import { useBlockProps, getSpacingPresetCssVar } from '@wordpress/block-editor';

/**
* Internal dependencies
*/
import { DEFAULT_HEIGHT } from './constants';

export default function save( { attributes } ) {
const { height, width, style } = attributes;
const { layout: { selfStretch } = {} } = style || {};
Expand All @@ -18,8 +13,7 @@ export default function save( { attributes } ) {
<div
{ ...useBlockProps.save( {
style: {
height:
getSpacingPresetCssVar( finalHeight ) || DEFAULT_HEIGHT,
height: getSpacingPresetCssVar( finalHeight ),
width: getSpacingPresetCssVar( width ),
},
'aria-hidden': true,
Expand Down

0 comments on commit 997934d

Please sign in to comment.