From 08eb130301af85218368450aac0a9d3215fe751d Mon Sep 17 00:00:00 2001 From: Amrit Rai <86003701+amritrai5757@users.noreply.github.com> Date: Thu, 9 Feb 2023 19:09:00 +0530 Subject: [PATCH] Resolved previous color selection i,e issue #111 --- js/ColorModule.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/js/ColorModule.js b/js/ColorModule.js index 44974e3..3b90a9b 100644 --- a/js/ColorModule.js +++ b/js/ColorModule.js @@ -158,14 +158,15 @@ const ColorModule = (() => { */ function addColorButtonEvent() { //generate random color - const newColor = new Color("hsv", Math.floor(Math.random()*360), Math.floor(Math.random()*100), Math.floor(Math.random()*100)).hex; - - //remove current color selection - document.querySelector('#colors-menu li.selected')?.classList.remove('selected'); + const newColor = new Color("hsv", Math.floor(Math.random()*360), Math.floor(Math.random()*100), Math.floor(Math.random()*100)).hex; //add new color and make it selected let addedColor = addColor(newColor); addedColor.classList.add('selected'); + + //remove previous color selection + document.querySelector('#colors-menu li.selected')?.classList.remove('selected'); + addedColor.style.width = squareSize + "px"; addedColor.style.height = squareSize + "px"; updateCurrentColor(newColor);