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

Fix duotone not showing in site editor style block level styles #55361

Merged
merged 8 commits into from
Oct 19, 2023
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,15 @@ function useMultiOriginColorPresets(
}

export function useHasFiltersPanel( settings ) {
const hasDuotone = useHasDuotoneControl( settings );

return hasDuotone;
return useHasDuotoneControl( settings );
}

function useHasDuotoneControl( settings ) {
return settings.color.customDuotone || settings.color.defaultDuotone;
return (
settings.color.customDuotone ||
settings.color.defaultDuotone ||
settings.color.duotone.length > 0
);
}

function FiltersToolsPanel( {
Expand Down Expand Up @@ -148,11 +150,6 @@ export default function FiltersPanel( {
const hasDuotone = () => !! value?.filter?.duotone;
const resetDuotone = () => setDuotone( undefined );

const disableCustomColors = ! settings?.color?.custom;
const disableCustomDuotone =
! settings?.color?.customDuotone ||
( colorPalette?.length === 0 && disableCustomColors );

const resetAllFilter = useCallback( ( previousValue ) => {
return {
...previousValue,
Expand Down Expand Up @@ -210,12 +207,9 @@ export default function FiltersPanel( {
<DuotonePicker
colorPalette={ colorPalette }
duotonePalette={ duotonePalette }
disableCustomColors={
disableCustomColors
}
disableCustomDuotone={
disableCustomDuotone
}
// TODO: Re-enable both when custom colors are supported for block-level styles.
disableCustomColors
disableCustomDuotone
value={ duotone }
onChange={ setDuotone }
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,7 @@ function ScreenBlock( { name, variation } ) {
inheritedValue={ inheritedStyleWithLayout }
value={ styleWithLayout }
onChange={ setStyle }
settings={ {
...settings,
color: {
...settings.color,
customDuotone: false, //TO FIX: Custom duotone only works on the block level right now
},
} }
settings={ settings }
includeLayoutControls
/>
) }
Expand Down
Loading