From c2633eb08cbec54c50ebbe2f403ea6d83a9d0ac3 Mon Sep 17 00:00:00 2001 From: Valter Lorran Date: Fri, 3 Jan 2025 16:19:20 -0300 Subject: [PATCH 1/2] Fix the color palettes --- projects/plugins/wpcomsh/custom-colors/colors.php | 2 +- projects/plugins/wpcomsh/custom-colors/js/colors-control.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/projects/plugins/wpcomsh/custom-colors/colors.php b/projects/plugins/wpcomsh/custom-colors/colors.php index 3362f2ff7bb63..93fafa904ca1c 100644 --- a/projects/plugins/wpcomsh/custom-colors/colors.php +++ b/projects/plugins/wpcomsh/custom-colors/colors.php @@ -389,7 +389,7 @@ public static function register_scripts_and_styles() { // register scripts wp_register_script( 'Color.js', plugins_url( 'js/color.js', __FILE__ ), array(), '20121210', true ); wp_register_script( 'colors-instapreview', plugins_url( 'js/colors-theme-preview.js', __FILE__ ), array( 'customize-preview', 'jquery', 'Color.js' ), '20121210', true ); - wp_register_script( 'colors-tool', plugins_url( 'js/colors-control.js', __FILE__ ), array( 'customize-controls', 'iris' ), '20160726', true ); + wp_register_script( 'colors-tool', plugins_url( 'js/colors-control.js', __FILE__ ), array( 'customize-controls', 'iris' ), '20250102', true ); wp_register_script( 'spin', plugins_url( 'js/spin.js', __FILE__ ), array(), '1.3', true ); wp_register_script( 'jquery.spin', plugins_url( 'js/jquery.spin.js', __FILE__ ), array( 'spin' ), '20210111', true ); } diff --git a/projects/plugins/wpcomsh/custom-colors/js/colors-control.js b/projects/plugins/wpcomsh/custom-colors/js/colors-control.js index 2cbb1fa480250..eb3c9db6c72ab 100644 --- a/projects/plugins/wpcomsh/custom-colors/js/colors-control.js +++ b/projects/plugins/wpcomsh/custom-colors/js/colors-control.js @@ -308,7 +308,8 @@ const morePaletteClickHandler = function () { // Load palettes into a client-side cache 40 at a time // and refresh that cache one page before it's necessary. - if ( ct.paletteIndex <= ct.palettes.length - ct.palettesAtATime ) { + const lastIndex = Math.max( ct.palettes.length, ct.palettes.length - ct.palettesAtATime ); + if ( lastIndex > ct.paletteIndex ) { ct.showPalettes( ct.paletteIndex ); } @@ -766,6 +767,9 @@ // Construct the color palettes for ( let i = paletteIndex, _len = paletteIndex + 6; i < _len; i++ ) { + if ( undefined === ct.palettes[ i ] ) { + continue; + } const new_palette = $( '