Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
4766831
add logic for custom color boolean for borders
Oct 15, 2025
999b0ef
add tests to verify color picker is visible or not visible
Oct 16, 2025
db9e443
Merge branch 'WordPress:trunk' into bugfix/respect-custom-color-boole…
n8finch Jun 2, 2026
6a71646
Merge branch 'WordPress:trunk' into bugfix/respect-custom-color-boole…
n8finch Jun 2, 2026
ba662c7
add wrapper for color palette
n8finch Jun 2, 2026
fdbc438
Update packages/components/src/border-box-control/test/index.tsx
n8finch Jun 3, 2026
7d098b5
Update packages/components/src/border-box-control/test/index.tsx
n8finch Jun 3, 2026
6ddfc06
add tests to check that no colors will also disable the color picker
n8finch Jun 3, 2026
ffa793f
update tests to check color guard
n8finch Jun 4, 2026
a04bdd7
remove single use function
n8finch Jun 4, 2026
a539cbd
resolve merge conflicts
n8finch Jun 5, 2026
605653c
remove tests from BorderBoxControl
n8finch Jun 5, 2026
3834cb7
update tests and location
n8finch Jun 5, 2026
dc69078
Merge branch 'trunk' into bugfix/respect-custom-color-boolean-from-th…
n8finch Jun 5, 2026
f57c190
remove custom prop
n8finch Jun 5, 2026
3346ca9
lint files
n8finch Jun 8, 2026
83afdd5
update check to return null Vstack
n8finch Jun 8, 2026
f0685e8
Merge branch 'WordPress:trunk' into bugfix/respect-custom-color-boole…
n8finch Jun 8, 2026
3e2e58b
update changelog
n8finch Jun 8, 2026
6bcb5db
Update packages/components/CHANGELOG.md
n8finch Jun 9, 2026
a01c105
Update packages/components/src/color-palette/index.tsx
n8finch Jun 9, 2026
e68122d
update tests to ColorPalette
n8finch Jun 9, 2026
df660f4
update merge conflicts
n8finch Jun 9, 2026
6265565
Update packages/components/src/color-palette/index.tsx
n8finch Jun 9, 2026
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
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export default function BorderPanel( {
defaultControls = DEFAULT_CONTROLS,
} ) {
const colors = useColorsPerOrigin( settings );
const areCustomSolidsEnabled = settings?.color?.custom;
Comment thread
aaronrobertshaw marked this conversation as resolved.
Resolved
const decodeValue = useCallback(
( rawValue ) => getValueFromVariable( { settings }, '', rawValue ),
[ settings ]
Expand Down Expand Up @@ -270,6 +271,7 @@ export default function BorderPanel( {
>
<BorderBoxControl
colors={ colors }
disableCustomColors={ ! areCustomSolidsEnabled }
enableAlpha
enableStyle={ showBorderStyle }
onChange={ onBorderChange }
Expand Down
76 changes: 76 additions & 0 deletions packages/components/src/border-box-control/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,82 @@ describe( 'BorderBoxControl', () => {
} )
).not.toBeInTheDocument();
} );

it( 'should disable the custom color picker when disableCustomColors is true', async () => {
const user = userEvent.setup();

// disableCustomColors = true → custom picker should NOT appear
render( <TestBorderBoxControl { ...props } disableCustomColors /> );

const colorButton = screen.getByLabelText( toggleLabelRegex );
await user.click( colorButton );

// Wait to make sure the dropdown opens
await waitFor( () =>
expect(
screen.queryByRole( 'button', {
name: 'Custom color picker',
} )
).not.toBeInTheDocument()
);
} );

it( 'should show the custom color picker when disableCustomColors is false', async () => {
const user = userEvent.setup();

// disableCustomColors = false → custom picker SHOULD appear
render(
<TestBorderBoxControl { ...props } disableCustomColors={ false } />
);

const colorButton = screen.getByLabelText( toggleLabelRegex );
await user.click( colorButton );

await waitFor( () =>
expect(
screen.getByRole( 'button', {
name: 'Custom color picker',
} )
).toBeVisible()
);
} );

it( 'should render the color palette when colors is greater than 0', async () => {
const user = userEvent.setup();
// colors is set to a non-empty array above, so the color palette should appear
render( <TestBorderBoxControl { ...props } /> );

const colorButton = screen.getByLabelText( toggleLabelRegex );
await user.click( colorButton );

// Wait to make sure the dropdown opens
await waitFor( () =>
expect(
screen.getByRole( 'listbox', {
name: 'Custom color picker',
} )
).toBeVisible()
);
} );

it( 'should not render the color palette when colors is 0', async () => {
const user = userEvent.setup();
// colors is set to an empty array above, so the color palette should not appear
render( <TestBorderBoxControl { ...props } colors={ [] } /> );

const colorButton = screen.getByLabelText( toggleLabelRegex );
await user.click( colorButton );

// Wait to make sure the dropdown opens
await waitFor( () =>
expect(
screen.queryByRole( 'listbox', {
name: 'Custom color picker',
} )
).not.toBeInTheDocument()
);
} );

} );

describe( 'Split view rendering', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,17 +203,19 @@ const BorderControlDropdown = (
const renderContent = () => (
<DropdownContentWrapper paddingSize="medium">
<VStack className={ popoverControlsClassName } spacing={ 6 }>
<ColorPalette
className={ popoverContentClassName }
value={ color }
onChange={ onColorChange }
{ ...{ colors, disableCustomColors } }
__experimentalIsRenderedInSidebar={
__experimentalIsRenderedInSidebar
}
clearable={ false }
enableAlpha={ enableAlpha }
/>
{ ( colors.length > 0 || ! disableCustomColors ) && (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a test to cover excluding the ColorPalette when there are no colors.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aaronrobertshaw got a test added for that.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick iteration @n8finch. Unfortunately, this test doesn't actually cover the change.

The guard you added prevents an empty ColorPalette wrapper from rendering when there are no colors and custom colors are disabled. This new test though only asserts that the "Custom color picker" button is absent. That button is never present when disableCustomColors is true regardless of this fix, so the test passes with or without your change and provides no regression protection.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aaronrobertshaw right, ok, there are four tests now covering:

  • custom color picker should be enabled
  • custom color picker should be disabled
  • the colors array has colors and should show the palette pickers
  • the colors array does not have colors and should not show the palette pickers

So that will check both sides of the guard now.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@n8finch unfortunately, the tests still do not cover the guards behaviour.

The guard prevents rendering the entire ColorPalette not just the custom color picker. So as it stands, the tests still don't protect against a regression here.

Also, I missed this on my earlier review but the tests here are for the BorderBoxControl not the BorderControl component that has actually been updated. That probably needs addressing too.

<ColorPalette
className={ popoverContentClassName }
value={ color }
onChange={ onColorChange }
{ ...{ colors, disableCustomColors } }
__experimentalIsRenderedInSidebar={
__experimentalIsRenderedInSidebar
}
clearable={ false }
enableAlpha={ enableAlpha }
/>
) }
{ enableStyle && isStyleSettable && (
<BorderControlStylePicker
label={ __( 'Style' ) }
Expand Down