From 901fdced904536951acda56a382c5694a75e2ab4 Mon Sep 17 00:00:00 2001 From: amritrai5757 Date: Tue, 3 Jan 2023 06:29:19 +0000 Subject: [PATCH] Fixed removal of all the colors from palette --- js/PaletteBlock.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/js/PaletteBlock.js b/js/PaletteBlock.js index 3035e43..5189d79 100644 --- a/js/PaletteBlock.js +++ b/js/PaletteBlock.js @@ -109,10 +109,17 @@ const PaletteBlock = (() => { endIndex = tmp; } - for (let i=startIndex; i<=endIndex; i++) { - coloursList.removeChild(coloursList.children[startIndex]); + if(coloursList.childElementCount > Math.abs(startIndex-endIndex)+1) { + for (let i=startIndex; i<=endIndex; i++) { + coloursList.removeChild(coloursList.children[startIndex]); + } + clearBorders(); + } else if(coloursList.childElementCount > 1){ + for (let i=startIndex; i