Skip to content

Commit

Permalink
Fix border support onChange handler
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronrobertshaw committed Feb 7, 2022
1 parent 471b6e0 commit 0289303
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/block-editor/src/hooks/border.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export function BorderPanel( props ) {
// attributes so that CSS classes can be used to apply those colors.
// e.g. has-primary-border-top-color.

let newBorderStyles;
let newBorderStyles = { ...newBorder };
let newBorderColor;
let newSideBorderColors;

Expand All @@ -199,6 +199,9 @@ export function BorderPanel( props ) {
// If so, determine if it belongs to a named color, in which case
// saved that named color to the block attribute and clear the
// style object's color property to avoid the inline style.
//
// This deliberately overwrites `newBorderStyles` to avoid mutating
// the passed object which causes problems otherwise.
newBorderStyles = {
top: { ...newBorder.top },
right: { ...newBorder.right },
Expand All @@ -223,8 +226,6 @@ export function BorderPanel( props ) {
}
} );
} else if ( newBorder?.color ) {
newBorderStyles = { ...newBorder };

// We have a flat border configuration. Apply named color slug to
// `borderColor` attribute and clear color style property if found.
const customColor = newBorder?.color;
Expand Down

0 comments on commit 0289303

Please sign in to comment.