Skip to content

Commit

Permalink
Merge 7e14a57 into aef276c
Browse files Browse the repository at this point in the history
  • Loading branch information
emeaguiar committed Jul 11, 2022
2 parents aef276c + 7e14a57 commit dfa39fa
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions plugin/assets/src/customizer/components/color-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,26 @@ const ColorControl = ( { defaultValue, params, onColorChange, mode } ) => {
};

useEffect( () => {
let hexColor = color.substring( 1 );

if ( hexColor.length === 3 ) {
hexColor = hexColor
.split( '' )
.map( hex => hex + hex )
.join( '' );
if ( color ) {
let hexColor = color.substring( 1 );

if ( hexColor.length === 3 ) {
hexColor = hexColor
.split( '' )
.map( hex => hex + hex )
.join( '' );
}

if ( 6 !== hexColor.length ) {
return;
}

onColorChange( `#${ hexColor }` );
api.previewer.send( 'materialDesignM3PaletteUpdate', {
color,
isDarkMode,
} );
}

if ( 6 !== hexColor.length ) {
return;
}

onColorChange( `#${ hexColor }` );
api.previewer.send( 'materialDesignM3PaletteUpdate', {
color,
isDarkMode,
} );
}, [ color ] );

return (
Expand Down Expand Up @@ -179,7 +181,7 @@ const ColorControl = ( { defaultValue, params, onColorChange, mode } ) => {
<MaterialColorPalette
value={ color }
onChange={ value => {
onChange( value );
onChange( value ?? '#ffffff' ); // Use white as default.
} }
materialColorsOnly={ true }
/>
Expand Down

0 comments on commit dfa39fa

Please sign in to comment.