gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Spacer block: Fill vertical space when within a Row block

Open richtabor opened this issue 3 years ago • 1 comments

When added as a direct child to a Row block, I'd expect the Spacer block to fill the available space (height). That would make the block easier to select and manipulate.

Currently you need to find the exact 24px space to properly select the block.

CleanShot 2023-04-19 at 18 49 40

richtabor avatar Apr 19 '23 22:04 richtabor

Thanks for sharing the issue ! i have analysed issue and below is my proposed solution for it.

Modifications in styling ( style.css )

  • We will add CSS rules targeting .is-layout-flex > .wp-block-spacer and .is-layout-grid > .wp-block-spacer.
  • Set align-self: stretch; to force the spacer to span the entire cross-axis of its flex/grid parent.
  • This ensures that in a Row block (horizontal flex), the spacer matches the row's height. In a Stack block (vertical flex), it matches the stack's width.

Modifications in Edit function of Spacer block

  • In the SpacerEdit component, there is a hardcoded height: 24 inline style applied when inheritedOrientation === 'horizontal'.
  • We will change this logic so height evaluates to undefined ( or removed ) if its inside a flex layout, or just remove the 24px hardcode, allowing align-self: stretch from our css to take effect without being constrained by an inline height: 24px limit.
  • We will verify that the invisible clickable area ( ::before pseudo element in styling ) still functions properly or is no longer solely responsible for editability since the block itself will stretch.

Above is my implementation plan, if it looks good i would like to work on this issue and go ahead with PR for this issue

dpmehta avatar Mar 10 '26 12:03 dpmehta