Skip to content

Commit

Permalink
Borders: Maintain radius in Global Styles (#49950)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronrobertshaw authored Apr 20, 2023
1 parent eb08935 commit b44e495
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/edit-site/src/components/global-styles/border-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ export default function BorderPanel( { name, variation = '' } ) {
const settings = useSettingsForBlockElement( rawSettings, name );

const onChange = ( newStyle ) => {
if ( ! newStyle?.border ) {
setStyle( newStyle );
return;
}

// As Global Styles can't conditionally generate styles based on if
// other style properties have been set, we need to force split
// border definitions for user set global border styles. Border
Expand All @@ -77,7 +82,8 @@ export default function BorderPanel( { name, variation = '' } ) {
// the `border` style property. This means if the theme.json defined
// split borders and the user condenses them into a flat border or
// vice-versa we'd get both sets of styles which would conflict.
const border = applyAllFallbackStyles( newStyle?.border );
const { radius, ...newBorder } = newStyle.border;
const border = applyAllFallbackStyles( newBorder );
const updatedBorder = ! hasSplitBorders( border )
? {
top: border,
Expand All @@ -92,7 +98,7 @@ export default function BorderPanel( { name, variation = '' } ) {
...border,
};

setStyle( { ...newStyle, border: updatedBorder } );
setStyle( { ...newStyle, border: { ...updatedBorder, radius } } );
};

return (
Expand Down

0 comments on commit b44e495

Please sign in to comment.