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

Borders: Maintain radius in Global Styles #49950

Merged
merged 1 commit into from
Apr 20, 2023
Merged
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
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