Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
12 changes: 11 additions & 1 deletion packages/block-editor/src/hooks/border-color.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import classnames from 'classnames';
import { addFilter } from '@wordpress/hooks';
import { __ } from '@wordpress/i18n';
import { createHigherOrderComponent } from '@wordpress/compose';
import { useState } from '@wordpress/element';

/**
* Internal dependencies
Expand Down Expand Up @@ -48,8 +49,17 @@ export function BorderColorEdit( props ) {
const colors = useSetting( 'color.palette' ) || EMPTY_ARRAY;
const disableCustomColors = ! useSetting( 'color.custom' );
const disableCustomGradients = ! useSetting( 'color.customGradient' );
const [ colorValue, setColorValue ] = useState(
getColorObjectByAttributeValues(
colors,
borderColor,
style?.border?.color
)?.color
);

const onChangeColor = ( value ) => {
setColorValue( value );

const colorObject = getColorObjectByColorValue( colors, value );
const newStyle = {
...style,
Expand All @@ -71,7 +81,7 @@ export function BorderColorEdit( props ) {
return (
<ColorGradientControl
label={ __( 'Color' ) }
value={ borderColor || style?.border?.color }
colorValue={ colorValue }
colors={ colors }
gradients={ undefined }
disableCustomColors={ disableCustomColors }
Expand Down
2 changes: 1 addition & 1 deletion packages/edit-site/src/components/sidebar/border-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export default function BorderPanel( {
{ hasBorderColor && (
<ColorGradientControl
label={ __( 'Color' ) }
value={ borderColor }
colorValue={ borderColor }
colors={ colors }
gradients={ undefined }
disableCustomColors={ disableCustomColors }
Expand Down