Skip to content

Commit

Permalink
Fix invalid Spacer markup when set to fill (WordPress#51317)
Browse files Browse the repository at this point in the history
* Fix invalid Spacer markup when set to fill

* Try unsetting default height in save

* Update comment

Co-authored-by: Ramon <ramonjd@users.noreply.github.com>

---------

Co-authored-by: Ramon <ramonjd@users.noreply.github.com>
  • Loading branch information
2 people authored and sethrubenstein committed Jul 13, 2023
1 parent 06e62fd commit 7d3c398
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/block-library/src/spacer/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@
*/
import { useBlockProps, getSpacingPresetCssVar } from '@wordpress/block-editor';

export default function save( { attributes: { height, width } } ) {
export default function save( { attributes } ) {
const { height, width, style } = attributes;
const { layout: { selfStretch } = {} } = style || {};
// If selfStretch is set to 'fill' or 'fit', don't set default height.
const finalHeight =
selfStretch === 'fill' || selfStretch === 'fit' ? undefined : height;
return (
<div
{ ...useBlockProps.save( {
style: {
height: getSpacingPresetCssVar( height ),
height: getSpacingPresetCssVar( finalHeight ),
width: getSpacingPresetCssVar( width ),
},
'aria-hidden': true,
Expand Down

0 comments on commit 7d3c398

Please sign in to comment.