Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/block-library/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

- Query: List the existing terms in the taxonomy filters, so categories and tags can be browsed and selected instead of recalled and typed. The controls now use `SearchableChipSelectControl` from `@wordpress/ui` ([#82583](https://github.com/WordPress/gutenberg/pull/82583)).

### Bug Fixes

- Spacer: Hide resize handles when custom spacing sizes are disabled, preserving preset dimensions ([#84518](https://github.com/WordPress/gutenberg/pull/84518)).

## 11.2.0 (2026-10-07)

### Enhancements
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/spacer/edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ const SpacerEdit = ( {
} ) }
>
{ blockEditingMode === 'default' &&
! disableCustomSpacingSizes &&
resizableBoxWithOrientation( inheritedOrientation ) }
</div>
{ ! isFlexLayout && (
Expand Down
134 changes: 134 additions & 0 deletions test/e2e/specs/editor/blocks/spacer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,140 @@ test.describe( 'Spacer', () => {
).toBeFocused();
} );

for ( const orientation of [ 'vertical', 'horizontal' ] ) {
test( `respects custom spacing restrictions for a ${ orientation } spacer`, async ( {
editor,
page,
} ) => {
const originalDisableCustomSpacingSizes = await page.evaluate(
() =>
window.wp.data.select( 'core/block-editor' ).getSettings()
.disableCustomSpacingSizes
);
const isHorizontal = orientation === 'horizontal';
const dimension = isHorizontal ? 'width' : 'height';
let selectedPreset = 'var:preset|spacing|40';
const spacerAttributes = isHorizontal
? {
width: selectedPreset,
style: {
layout: {
selfStretch: 'fixed',
flexSize: 'var(--wp--preset--spacing--40)',
},
},
}
: { height: selectedPreset };
const spacerBlock = {
name: 'core/spacer',
attributes: spacerAttributes,
};
const getSpacerAttributes = async () => {
const [ block ] = await editor.getBlocks();
return ( isHorizontal ? block.innerBlocks[ 0 ] : block )
.attributes;
};
const setCustomSpacingDisabled = ( disabled ) =>
page.evaluate( ( disableCustomSpacingSizes ) => {
window.wp.data
.dispatch( 'core/block-editor' )
.updateSettings( { disableCustomSpacingSizes } );
}, disabled );

try {
await setCustomSpacingDisabled( true );
await editor.insertBlock(
isHorizontal
? {
name: 'core/group',
attributes: {
layout: {
type: 'flex',
orientation: 'horizontal',
},
},
innerBlocks: [ spacerBlock ],
}
: spacerBlock
);
const spacer = editor.canvas.getByRole( 'document', {
name: 'Block: Spacer',
exact: true,
} );
const resizeHandle = spacer.locator(
'.components-resizable-box__handle'
);
await spacer.click();
await expect( resizeHandle ).toHaveCount( 0 );
await expect
.poll( getSpacerAttributes )
.toMatchObject( spacerAttributes );

if ( ! isHorizontal ) {
await editor.openDocumentSettingsSidebar();
await page
.getByRole( 'slider', { name: 'Height', exact: true } )
.press( 'ArrowRight' );
selectedPreset = 'var:preset|spacing|50';
}
await expect.poll( getSpacerAttributes ).toMatchObject( {
[ dimension ]: selectedPreset,
...( isHorizontal && { style: spacerAttributes.style } ),
} );

await editor.saveDraft();
await page.reload();
await spacer.waitFor();
await setCustomSpacingDisabled( true );
await spacer.click();
await expect( resizeHandle ).toHaveCount( 0 );
await expect.poll( getSpacerAttributes ).toMatchObject( {
[ dimension ]: selectedPreset,
...( isHorizontal && { style: spacerAttributes.style } ),
} );

await setCustomSpacingDisabled( false );
await expect( resizeHandle ).toBeVisible();
const spacerBounds = await spacer.boundingBox();
const handleBounds = await resizeHandle.boundingBox();
const handleX = handleBounds.x + handleBounds.width / 2;
const handleY = handleBounds.y + handleBounds.height / 2;
await page.mouse.move( handleX, handleY );
await page.mouse.down();
await page.mouse.move(
handleX + ( isHorizontal ? 50 : 0 ),
handleY + ( isHorizontal ? 0 : 50 ),
{ steps: 5 }
);
await page.mouse.up();
await expect
.poll(
async () => ( await getSpacerAttributes() )[ dimension ]
)
.toMatch( /^\d+px$/ );
const resizedAttributes = await getSpacerAttributes();
expect(
parseFloat( resizedAttributes[ dimension ] )
).toBeGreaterThan( spacerBounds[ dimension ] );
expect( resizedAttributes ).toMatchObject( {
[ dimension ]: expect.stringMatching( /^\d+px$/ ),
...( isHorizontal && {
style: {
layout: {
selfStretch: 'fixed',
flexSize: resizedAttributes.width,
},
},
} ),
} );
} finally {
await setCustomSpacingDisabled(
originalDisableCustomSpacingSizes
);
}
} );
}

test( 'should work in theme without spacing units support', async ( {
editor,
page,
Expand Down
Loading