Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block Supports: Use empty initial value for border-radius #29263

Closed
wants to merge 1 commit into from
Closed
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
27 changes: 9 additions & 18 deletions packages/block-editor/src/hooks/border-radius.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
import { RangeControl } from '@wordpress/components';
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import { cleanEmptyObject } from './utils';

const MIN_BORDER_RADIUS_VALUE = 0;
const MAX_BORDER_RADIUS_VALUE = 50;

Expand All @@ -25,19 +20,15 @@ export function BorderRadiusEdit( props ) {
} = props;

const onChange = ( newRadius ) => {
let newStyle = {
...style,
border: {
...style?.border,
radius: newRadius,
setAttributes( {
style: {
...style,
border: {
...style?.border,
radius: newRadius,
},
},
};

if ( newRadius === undefined ) {
newStyle = cleanEmptyObject( newStyle );
}

setAttributes( { style: newStyle } );
} );
};

return (
Expand All @@ -46,7 +37,7 @@ export function BorderRadiusEdit( props ) {
label={ __( 'Border radius' ) }
min={ MIN_BORDER_RADIUS_VALUE }
max={ MAX_BORDER_RADIUS_VALUE }
initialPosition={ 0 }
initialPosition=""
allowReset
onChange={ onChange }
/>
Expand Down